.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Technology News >> General >> Post New Resource Bookmark and Share   

 Subscribe to Tech News

Detecting Memory leak in Visual Studio (Debug mode)

Posted By:elizas       Posted Date: May 04, 2010    Points: 10    Category: General    URL: http://www.dotnetspark.com  

The memory leak information is printed on "Output" window. 
[ This advantage is in "Debug" mode only. ]
int _tmain()
int* ptr = NULL;
ptr = (int*)malloc(sizeof(int)*20);
for( int i=0; i<20; ++i )
ptr[i] = i;
#ifndef NDEBUG
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Get current flag
flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit
_CrtSetDbgFlag(flag); // Set flag to the new value
printf("\n\nPress Enter...");
return 0;

 Subscribe to Tech News


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

    Read also another Resources from the same Author

Find More Technology News Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend