C/C++ Heap Checking
Ron (2686) 63 posts |
Hello Are there any guides as to how the heap works? I have an App that uses a library that runs for several days slowly increasing the wimp slot until it exhausts the wimp slot. I’ve got a version of Fortify & Memcheck to try but don’t suspect they’ll show anything extra. Cheers |
Jeffrey Lee (213) 6048 posts |
I’m assuming you’re using the shared C library? There are some comments in the source code which describe the overall behaviour.
I’m not aware of any. You might have to go down the route of writing your own wrappers for malloc/free so that you can track the info manually (or find a wrapper elsewhere on the internet). For checking whether it’s a memory leak, you could just keep a count of how many instances of each object type are currently allocated. Although this might not work so well with variable-length objects (e.g. data buffers which can grow)
Yes, it should do. However it does coalesce free blocks in a lazy manner, which looks like it might cause unnecessary heap growth in some situations
Rather than waiting for the wimp slot to hit 512MB limit, you could modify the app so that it kills itself much sooner, e.g. 16MB. |
Ron (2686) 63 posts |
Thanks for replying Jeffrey.
Yes I am. I should have said. I did find a similar document on the RISCOS Ltd website but wasn’t sure that was for the SCL malloc code. As far as I can tell, it’s fragmenting rather than a classic memory leak. Constructors match destructors. Some tuning may be in order as I’m definately not optimizing the initial allocated block size or expansion rate. Thankyou Ron |