If we move the level of abstraction up just a bit, the next thing we encounter is memory pools. ACE_Malloc<> provides this to us.
In this tutorial, we'll use ACE_Malloc<> to create a memory pool that is sharable between a client and server. We'll use a memory mapped file to provide the physical storage but shared memory works just as well.
Kirthika's abstract:
In this tutorial, a ACE_Malloc class with ACE_MMAP_MEMORY_POOL and a semophore for syncronisation has been used. This is locked by the server initially and released after it writes into it so that the client waiting for it can go ahead and do its job. There is yet another semaphore used by the server to exit only after the client has finished its task, which is locked by the client at the start and released when its done.
Some more information regarding memory management: ACE also provides the ACE_Allocator class which uses dynamic binding and is flexible, though at a cost of using virtual pointer tables. Also, there is an ACE_Allocator_Adapter class which has an ACE_Allocator interface but ACE_Malloc functionality.
Bottomline: Memory can be managed either using the ACE_Allocator set of classes which uses polymorphism and is thus flexible but not as efficient as the templatised version which is the ACE_Malloc set of classes which are more efficient but not as felxible.