Diagnosing heap usage

I have a program that is failing to allocate a 4K block with 15K of free memory, so clearly I have some heap fragmentation. GC(true) does not fix it. I know I could pre-allocate the buffer earlier in the program life-cycle, but the max buffer size isn’t known for certain. I am using this buffer to load a .pe file from flash, so pre-allocating the buffer would set an artificial upper limit to the loadable modules.

My core question though is this : Debug.DumpHeap does not seem to exist in 4.3 (and according to the docs, not in 4.2 either), so what do you use to determine what you have in your heap at runtime? I don’t have access to GHI assys in this project, so I am looking for generic NETMF solutions, if any exist. How do you go about profiling your heap usage?

Calling debug.gc will print what you need in the output window but this is disabled by default. Enable it using debug.enablegcmessages. I am using my phone so I am not sure about the exact name.

Looks like the right answer, but the firmware I am using does not have that option baked in, or at least it doesn’t output anything more than (false) does. Works on Spider but not on my non-GHI firmware. Before I go rebuild firmware though, I have found some ways to re-jigger the code to kill off some likely suspects, which is an experiment I can complete faster than a new firmware.

Thanks much - I’ll certainly need this later.