I work with a RCM6700 and Dynamic C 10.72.
I have the following runtime error although my program is not using any dynamic allocation.
Run time error : Heap usage error detected
file : MALLOC.LIB
function : mspace_free
line : 3313
My program uses root and xmem storage and I suspect that some line of code is updating root memory while I intend to update xmem or vice versa.
When I get the runtime error DC crashes and I cannot go back and find out how my program got there. How can I debug this situation to itendify the faulty line(s) of code(s)?
These things are always difficult to track down as the offending code may have done its work long before the call to mspace_free().
You could try enabling debug in malloc.lib and putting a break point on the error detection code in mspace_free(). It might be possible to look at the memory block where the error occurred to determine where the corruption came from.
One thing that helps with DC 10.72 (and earlier DC 10 versions) is the support for far pointers and far data which makes it easier to allocate variables in different areas of memory without having to manually move data between xmem and root. Much of the time you don’t have to think about it unless you are trying to reduce code size or speed up some operations by explicitly placing data in root memory.
You might look at defining the USAGE_ERROR_ACTION macro to call some of your own code to do some post mortem dumps etc when the memory error occurs.