G
GJ
Hi,
Can we trace a memory leak in a C program without using any specific tools
like purifier.
Can we trace a memory leak in a C program without using any specific tools
like purifier.
GJ said:Hi,
Can we trace a memory leak in a C program without using any specific tools
like purifier.
makuchaku said:You can override the malloc/free functions in your scope & detect leaks
in free.
Each malloc call should be free'd in free. If not, flag a memory leak...
Memory is not "leaked" until all pointers to the memory (besides that
stored in your proposed memory management system) are gone. How do
you propose to verify that your memory management system has the one
and only pointer to some block of memory?
What you'd need is a malloc substitute that records where and possibly when
each block was originally allocated, and then at program end, list the ones
that aren't freed.
This will end up with false positives, particularly
in case of an exit other than returning from main(), but this
information will give you at least a place to start looking
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.