This post is part two of my previous post, HP-UX, shared memory, and you.
I spent today implementing a shared library to override the C runtime library’s memory management routines: malloc, realloc and free, which passes the memory management requests along to the manager to allocate from the pool of shared memory. To test it, I wrote a small program that randomly performs allocations, reallocations, and deallocations for a set number of iterations to verify the correct operation of the shared library and the manager. For allocations and reallocations, the program also randomises the length of the memory block requested, with the upper limit to this random length set to 128MB. The results, surprisingly enough, showed that my shared memory implementation serviced the allocations significantly faster than using the base CRT methods. I’m not sure why this is yet.
With real world applications (i.e., standard UNIX programs such as ls and grep), however, my shared memory implementation falls behind the CRT. When I iron out the kinks left in the code tomorrow, I’ll be evaluating the performance of the shared memory implementation using the actual services on the development environment.