Reputation: 5404
I would like to detect memory leaks in visual studio c++. But instead of checking the whole solution, I would like to check for memory leaks between two code lines or a function. I don't want to check for memory leaks in the whole solution. For example:
// some code
startMemoryLeakDetection()
// other code
stopAndReportMemoryLeakDetection()
// some other code
Can anyone guide me to the necessary tools / programs?
Upvotes: 1
Views: 503
Reputation: 3407
You can identify memory leak by using CRT dump and also using memory state comparison to get the statistics. Please refer steps given in MSDN for more details
_CrtMemCheckpoint( &s1 );
// memory allocations take place here
_CrtMemCheckpoint( &s2 );
if ( _CrtMemDifference( &s3, &s1, &s2) )
_CrtMemDumpStatistics( &s3 );
http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx
Upvotes: 3