Skip to content

Instantly share code, notes, and snippets.

@zsh-89
Created July 3, 2014 02:00
Show Gist options
  • Save zsh-89/14dba930c76c97c79363 to your computer and use it in GitHub Desktop.
Save zsh-89/14dba930c76c97c79363 to your computer and use it in GitHub Desktop.
The one with expected behavior.
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#include <opencv2/opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
int main(void)
{
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
{
cv::Mat xx = cv::imread("B:/cc.png");
cv::imshow("win title", xx);
}
//int *p = new int;
return 0;
}
@zsh-89
Copy link
Author

zsh-89 commented Jul 3, 2014

No output because there's no memory leak.

But _CrtSetDbgFlag() have actually enabled the memory leak detection.
_CrtDumpMemoryLeaks() is called automatically and implicitly at the termination of this program because we have used _CrtSetDbgFlag properly.

Try uncomment //int *p = new int;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment