I forget the details, but I think I needed to add some special
Valgrind macros to my code, near where it called mmap. Let me know if
you'd like more information.
In the practice of computing, where we have so much latitude for
making a mess of it, mathematical elegance is not a dispensable
luxury, but a matter of life and death.
-- Edsger W. Dijkstra: My Hopes of Computing Science (EWD 709)
OK, what you want to do is: read the valgrind documentation and look
at the macros VALGRIND_CREATE_MEMPOOL, VALGRIND_MEMPOOL_ALLOC, and
VALGRIND_MEMPOOL_FREE. In my case, at least, those were all I needed
to tell valgrind "Hey, I'm managing my own memory here; please treat
the region that I just mapped as if it were part of the heap".