Potential memory leak

Dear community, thank you all for this nice piece of software!!

I’m using it with dicom images.

However I noticed a sort of bug:
After opening a couple of images (multislice MR), even though I close the scene, I find the slicer process being using a lot of RAM.
Here you are a screen.

Furthermore, when I close the program it seems like a destructor has not been invoked.


I’m using the latest nightly version!

Best regards

Thanks for the report - yes, we’d like to fix that.

Can you provide the exact steps to reproduce? (ideally using Slicer SampleData or some data you can share).

Working set is the size of memory pages recently used by the application. If the application releases memory, working set size may remain the same until the memory is needed for another process. So, this may be normal. If memory usage keep increasing when you repeatedly load a data and close the scene (e.g., working set is 2GB then 3GB, 4GB, 5GB, …) then that may indicate that there is a memory leak.

But the unfreed collections should not happen, so we should track down how to reproduce that.

1 Like

Dear all, thank you for your support.
Indeed, as you told, in my windows PC the unfreed RAM is reallocated when needed automatically.

NB: During the weekend I have only a Macbook Mojave to work, so I’ll post the steps to reproduce the error on monday. However I noticed that opening the same images on Slicer for MacOS the required RAM is much less (less than 1GB…). Could this be normal?

At the moment I can post a RT structure which is causing a slicer crash on MacOS. Probably it’s something similar to the problem found on Windows 7 but here the process closes.

Here you can find the RT file and the crash log.

  1. I load it on the DCM database.
  2. Select the node and load it

nothing more.

Thank you!!

Here I am.

Windows 7 Ultimate, SP1.

Nightly build 4.11.0-2019-07-10 r28371

  1. Download the DICOM zip file from the MultiVolumeExplorer documentation page.
  2. Load it on the DICOM browser (It took to me more than 15 mins to load on the database…i’m not sure it’s normal…) and import it as “MultiVolume by TriggerTime”
  3. Open the MultiVolumeExplorer plugin and set the input multivolume to the sample data and the input secondary volume to None.
  4. Select a frame (E.g. frame 20) and click Copy frame
  5. Quit the program without saving.

Here you are the problem.

I worked for 1h importing and copying frames, converting them into nrrd and saving them. At the end, I had tons of errors. I report here a couple of messages (not all)
error error2 error4

Thank you for the help!!

You can safely ignore memory leak warnings at application exit. They are for developers only. I think they should not be displayed in releases that you download. Have you built Slicer yourself?

What would you like to achieve? Is your only problem that memory leaks are reported when you shut down the application?

1 Like

I’ve downloaded the execuitable installer which should be compiled every night. I’ve changed nothing.
If you say it’s not a problem, for me it’s fine. It’s only a bit strange to have a page-long list of errors when you close the program. That’s why I made this post.

However I still have the crash problem I reported a couple o posts ago.

Best regards.

@GiulioBen Could you try downloading today’s Slicer preview release from https://download.slicer.org/ and let us know if you have the same issue of the memory leak warnings?

Those memory leak warnings displays are on by default when you manually build Slicer nightly. Maybe someone built Slicer manually, packaged it and then you installed it from that and not from the Slicer website.

1 Like

It’s definitely a problem if it happens for the Stable Release. By default, we should probably not run memory leak check on Preview Releases either (if we do it now then we should probably change the build scripts), as this is debug information only intended for developers.

Importing that RTSTRUCT crashes Slicer, because it is invalid: number of values in contour data must be 3 x number of contour points, but in the file there are only 1 x number of contour points.

We’ve tested SlicerRT DICOM importer on thousands of data sets but never encountered such error, that’s why we did not notice that this can crash the application. Now I’ve added an extra check to avoid crash in the future and report this as an error.

Let developers of the software that created this RTSTRUCT file know that they produce non-compliant DICOM files. The incorrectly set “number of contour points” is just one of the many issues in the file (for example, usage of coded entries are completely misinterpreted by the developers).


Thank you all. I downloaded and installed the last version of the nightly slicer and the same error message appears.

Anyway, if it’s just a debugging tool and a normal user can ignore it, i think we can close this post.

Thank you very much for the support!!

Thank you, Andras! .

@lassoan I came back to this thread to test if memory leaks are displayed using preview releases built by the factory machines and indeed they are displayed.

Using “3D Slicer 4.11.0-2019-08-22” downloaded from Slicer’s website and creating a leak such as a=slicer.mrmlScene.CreateNodeByClass("vtkMRMLScalarVolumeNode") in the python interactor and then closing Slicer, I received a vtk debug leaks output window. This was tested using a Windows 7 machine which the original poster was also using.

Does anyone know if testing of preview releases is using memory leaks output to determine faults? As in will a memory leak introduced during a specific test cause that test to fail if on Slicer close there are memory leaks?