I'm Using DCMTK-3.6.6
i have used DcmInputBufferStream for dcm file read. read buffer stream using DcmFileFormat. then save as dcm file.
here the sample code
Code: Select all
DcmInputBufferStream buffer_stream();
std::string outfilename = "E:\\tmp\\New\\test.dcm";
DcmFileFormat fileformat;
DcmInputBufferStream dcmStream;
dcmStream.setBuffer((void*)buffer, file_size);
dcmStream.setEos();
fileformat.transferInit();
OFCondition status = fileformat.read(dcmStream, EXS_Unknown, EGL_noChange); // when i commented this line there are no memory leak
dcmStream.releaseBuffer();
if (status.good())
{
DcmDataset *dataset = fileformat.getDataset();
dataset->read(dcmStream, EXS_LittleEndianImplicit);
auto xfer = dataset->getOriginalXfer();
auto status = fileformat.saveFile(outfilename.c_str(), xfer, EET_ExplicitLength, EGL_recalcGL, EPD_withoutPadding, 0, 0, EWM_fileformat);
if (status.good())
LINFO("Image saved Successfully: " << outfilename);
else
{
LERROR("Could Not Write DICOM File." << status.text());
}
dataset->clear();
}
fileformat.transferEnd();
fileformat.clear();
i have used 500MB dicom file. after saving the dicom file around 7 to 10 MB memory not clearing. if i try another time it will take another 7 to 10 MB will be increased.
can you please let me know what i have missed in my code