Hi everybody,
I have a small program which uses Opencv library. And I do not know why it produce memory leaks. Here is the all program code:
#include <opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif // _DEBUG
class C
{
public:
C();
~C();
void Test();
};
void C::Test()
{
IplImage * image = cvCreateImage(cvSize(640, 680), 8, 3);
cvReleaseImage(&image);
image = NULL;
}
int main(int argc, char** argv)
{
_CrtDumpMemoryLeaks();
}
And here is the Output window:
'CVSample.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'CVSample.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
Detected memory leaks!
Dumping objects ->
{135} normal block at 0x00454B18, 29 bytes long.
Data: < (KE /KE > 00 00 00 00 28 4B 45 00 2F 4B 45 00 00 00 00 00
{134} normal block at 0x00454AA0, 57 bytes long.
Data: < ( (JE > 00 00 00 00 28 00 00 00 00 00 00 00 28 4A 45 00
{133} normal block at 0x00454A28, 54 bytes long.
Data: < ( JE IE > 00 00 00 00 28 00 00 00 A0 4A 45 00 B0 49 45 00
{132} normal block at 0x004549B0, 53 bytes long.
Data: < ( (JE 0IE > 00 00 00 00 28 00 00 00 28 4A 45 00 30 49 45 00
{131} normal block at 0x00454930, 61 bytes long.
Data: < ( IE HE > 00 00 00 00 28 00 00 00 B0 49 45 00 B8 48 45 00
{130} normal block at 0x004548B8, 53 bytes long.
Data: < ( 0IE 8HE > 00 00 00 00 28 00 00 00 30 49 45 00 38 48 45 00
{129} normal block at 0x00454838, 61 bytes long.
Data: < ( HE GE > 00 00 00 00 28 00 00 00 B8 48 45 00 C0 47 45 00
{128} normal block at 0x004547C0, 56 bytes long.
Data: < ( 8HE > 00 00 00 00 28 00 00 00 38 48 45 00 00 00 00 00
Object dump complete.
The program '[2620] CVSample.exe: Native' has exited with code 0 (0x0).
If I define the class as below, the program will not report memory leaks.
class C
{
public:
C();
~C();
void Test(){
IplImage * image = cvCreateImage(cvSize(640, 680), 8, 3);
cvReleaseImage(&image);
image = NULL;
}
};
I do not know why ? please help ?