Hello,
I may have not searched thoroughly but I am surprised not to have found an issue about this:
itkGDCMSeriesFileNames seems to suffer from a huge memory leak: it relies on the gdcm::SerieHelper class which... has some issues like this commented call to delete
And looking at GCDM API doc, its authors seem well aware of the situation:

But you know... who read the doc anyway? (Please don't take this too seriously ;) )
So out of luck and running out of time, instead of patching ITK's GDCM I tried to use itkDCMTKSeriesFileNames which does not suffer from memory leaks, but... when you are out of luck you should stop trying:
itkDCMTKSeriesFileNames stores SeriesUID in a vector... which means that when you are querying Series UIDs you end up with duplicates (n files of the same series => n duplicated seriesUID): they should be stored in a set/unordered_set (or maybe in a hash map for linking series with their files). Not to mention that it lags behind itkGDCMSeriesFileName in terms of features:
- The recursive flag is not used
- The
AddSeriesRestriction function is a NOOP
- The series uids and filenames are recomputed at each call to
GetInputFileNames/GetFileNames("seriesUID")/GetSeriesUID but are stored as member variables: they could be used as cache values
Thank you very much for your time and for your work on this library.
Hello,
I may have not searched thoroughly but I am surprised not to have found an issue about this:
itkGDCMSeriesFileNamesseems to suffer from a huge memory leak: it relies on thegdcm::SerieHelperclass which... has some issues like this commented call to deleteAnd looking at GCDM API doc, its authors seem well aware of the situation:
But you know... who read the doc anyway? (Please don't take this too seriously ;) )
So out of luck and running out of time, instead of patching ITK's GDCM I tried to use
itkDCMTKSeriesFileNameswhich does not suffer from memory leaks, but... when you are out of luck you should stop trying:itkDCMTKSeriesFileNamesstores SeriesUID in a vector... which means that when you are querying Series UIDs you end up with duplicates (n files of the same series => n duplicated seriesUID): they should be stored in a set/unordered_set (or maybe in a hash map for linking series with their files). Not to mention that it lags behinditkGDCMSeriesFileNamein terms of features:AddSeriesRestrictionfunction is a NOOPGetInputFileNames/GetFileNames("seriesUID")/GetSeriesUIDbut are stored as member variables: they could be used as cache valuesThank you very much for your time and for your work on this library.