Shared memory and IPC

Wez Furlong wez at
Wed Sep 5 18:34:05 GMT 2001

On 05/09/01, "Rich Salz" <rsalz at> wrote:
> > > free, realloc etc. etc.  Memory allocated using the COM IMalloc must
> > > be passable directly to another process (ie: appear at the same address),
> Are you sure?  I just looked up IMalloc at and could
> find no example of that.

CoGetMalloc(MEMCTX_SHARED, &lpMalloc);
An excerpt from my MSDN library docs (you need to search for MEMCTX_SHARED,
it's in the COM Specification 0.9 and COM Library Memory Management Functions):

MEMCTX_SHARED returns an optionally-provided shared allocator; if the shared
allocator is not supported, E_INVALIDARG is returned. When supported, the
shared allocator returned by this function is an COM-provided implementation
of IMalloc interface, one which allocates memory in such a way that it can be
accessed by other process on the current machine simply by conveying the
pointer to said applications.2. Further, memory allocated by this shared
allocator in one application may be freed by the shared allocator in another.
Except when a NULL pointer is passed, the shared memory allocator never
answers -1 to IMalloc::DidAlloc; it always indicates that either did or did not
allocate the passed pointer.
> > is it possible to get memory allocated in one process to be shared
> > with another process *at the same address* on unix, os/2, nt, vms etc?
> Not for arbitrary processes that I'm aware of.

What if they had prior knowledge of the existence of the shared memory


More information about the samba-technical mailing list