Something simple that you could do is immediately assign a NULL to the
pointer just deleted.
delete(wildPtr); // or free(wildPtr);
wildPtr = NULL;
Your program should then blow up at the offending location rather than
access deleted/freed (but still available) memory. Start with global
pointers and then file-scope pointers and lastly function-scope pointers.
It's good practice to ALWAYS do this with any pointer of global or file
level scope.
deleting/freeing memory doesn't necessarily release the memory back to
the OS and the memory allocated might be retained by the memory
management subsystem for re-use.
Ed.
Paul M Foster wrote:
> I've got a C program I'm writing, in which something appears to be
> stepping on something else's memory. Does anyone have _personal_
> experience with a good memory checker/malloc replacement that might
> assist in debugging what's gone errant?
>
> Paul
>
>
>
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:15:10 EDT