Hello- I'm using the custom memory pool macros for the first time, and though I've read through all of Memcheck's documentation, there are a few questions I'm still not quite clear on. I'd also like to explain my custom memory allocation scheme, and how I'm planning on "tagging" it, so someone can help me if there are any glaring mistakes. In particular:
1. What is the relationship between the valgrind MALLOC/FREELIKE_BLOCK and Memcheck-specific MEMPOOL_ALLOC functions? If I'm carving out a chunk of memory, do I need to call them both? Also, am I correct in assuming that these functions take care of marking the memory as defined/undefined/noaccess? 2. I understand that I should use MAKE_MEM_NOACCESS to mark sections of memory that are used internally by the allocator, but won't this cause Memcheck to find errors whenever the allocator changes its own state? How does Memcheck know the difference between the allocator code and client code? Should I use VALGRIND_DISCARD for this? 3. Am I correct in assuming that CREATE_MEMPOOL only registers a pool and its base address with valgrind? It doesn't change the layout of memory at all? ===================================== The custom allocator setup is as follows: When the allocator is created, a large "arena" is malloc'd. The arena has a brief descriptor. For each object type that you wish to store in the arena, a pool is created. Pools may consist of one or more blocks (of constant size), and each block can hold a certain number of frames, one frame per object. For each pool, one block is the "home block" which contains descriptors for both the pool and the block, other blocks just have a block descriptor. Thus, when you wish to allocate space for an object, the pool associated with that object looks through its blocks for a free frame. If none are left, it creates a new block for that pool. My plan was thus: - When the arena is created, mark the entire space as NOACCESS - Each block (not pool) corresponds to a MEMPOOL, so whenever a block is created, CREATE_MEMPOOL is called - When an object is allocated, MEMPOOL_ALLOC is called, and MEMPOOL_FREE is used when it's freed Does this seem reasonable? Thanks for your help, Alex ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users