[Dcmlib] Re: ptotential memory leak without virtual destructor.

Mathieu Malaterre mathieu.malaterre at kitware.com
Sun Nov 14 01:51:18 CET 2004


Dennis,

   See my comments interlaced:

> I have tried to use gdcm. but after i exit my MFC appliaction. There are
> tons of memory leak about DICOM reading.
> It's very difficult to track this bug because it's dynamic...

Yes I know. This is in my list of TODO... you are welcome to send patches :)

> However, i found something is not correct with gdcm. the destructor of
> gdcm::ElementSet is not vritual.(it's bad)
> gdcm::Document is derived from gdcm::ElementSet. it's destructor is virtual.
> the base class gdcm::DocEntry also has 
> a  vritual destructor. This will bring unpredictable result as i read from
> http://www.codersource.net/cpp_virtual_destructors.html

Reading the link you mention you see that only the base class need to specify the keywaord virtual. C++ mechanism propagate this along all derived class. So no worry gdcm::ElementSet is also virtual.

> By the way, in the file gdcmutil.cxx. the function has called va_start, but
> there is no va_end to set args to 0.
> I think that it maybe a potential bug.

I agree. I have patch gdcm CVS, gdcm 0.6 and later I'll patch ITK. Thanks for report. How did you find out this ? Do you use a special tool ?

Thanks
Mathieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.creatis.insa-lyon.fr/pipermail/dcmlib/attachments/20041113/4811dc23/attachment.html>


More information about the Dcmlib mailing list