I have a code of about 10,000 lines. I have to maintain a track for new and delete statements to check and avoid memory leaks. i can use new libraries or functions but i can’t change the code. How can i do it? Please donot suggest for any memory cheking tool.
Any help would be appreciated.
Link to a heap implementation, which implements the global new and delete operators, and which keeps track of how many times each one is called.
There are two ways to do that.
The global new operator needs to look at (and perhaps decode) the call stack when it’s invoked, to see/remember where it’s being called from each time it’s called.
See the answers to Overriding “new” and Logging data about the caller