The Apache API provides the Pool mechanism for C programmers to
use for resource allocation, including memory allocations. The
Pool API allows programmers to allocate memory with
ap_pcalloc()
or other related functions. Apache takes
care of releasing the resources allocated from its pools at the
appropriate time. This hybrid of traditional C memory management
and garbage collection is intuitive to C programmers and avoids
memory leaks.
Unfortunately C++ programmers typically have no use for C style
memory management. C++ programmers must use the operators
new()
and delete()
so that constructors
and destructors of the allocated objects can be called.
Currently my solution has been to just always remember to
delete
anything I allocate with new
. I
believe this is the easiest solution but I would like to leave
this space as a placemarker for potential examples of using custom
new
operators STL allocators that use the Pool
API.
If you allocate memory during the child initialization phase there is a child exit phase in which you can define a handler to deallocate that memory.