I define a class CTest
class CTest
{
public:
DcmDataset *dataset;
DcmFileFormat fileformat;
CTest()
{
dataset = fileformat.getDataset();
}
~CTest()
{
delete dataset; //free memory at heap associated to this pointer
}
};
and in main function, I delare
main()
{
CTest *test = new CTest;
//adding other lines if needed
delete test; //free memory at heap assocaited to this pointer
}
Problem:
It is encountered the problem of "Unhandled exception at 0x0050d297 in testfolder2.exe: 0xC0000005: Access violation reading location 0xfeeefeee."
Question:
1) If I only remove the "delete dataset" line in the deconstuctor, or if I only remove "delete test" line in main function, there is no error in run-time, but I wonder if there is memory leak assocaited with it.
2) If I replace "delete dataset" by "delete fileformat.getAndRemoveDataset()", no error in run-time, does getAndRemoveDataset free mmeory?
Thanks,
snie
________
Ios games
________
Rhode island medical marijuana
Will I have memory leak problem?
Moderator: Moderator Team
Will I have memory leak problem?
Last edited by snie on Thu, 2011-02-17, 21:49, edited 2 times in total.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 0 guests