# Slicer becomes slower over time during surgical navigation cases

**URL:** https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176
**Category:** Support
**Created:** [October 15, 2021, 7:12pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176 "2021-10-15T19:12:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Prashant\_Pandey](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@Prashant\_Pandey](https://discourse.slicer.org/u/Prashant_Pandey)
#### Post date: [October 15, 2021, 7:12pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/1 "2021-10-15T19:12:29Z")

</div>

We’re using Windows 10, Slicer 4.11, SlicerIGT and PLUS to do navigated surgery. We’re streaming data from an NDI optical tracker and an ultrasound probe using OpenIGTLink.

We are running into problems with Slicer slowing down significantly over time. Usually by the time the surgeon is interacting with the instruments, Slicer and the other software has been running on our system for 1-2 hours. When interacting with Slicer, the GUI is slow to respond and all simple or complex processing (i.e. scrolling through slices or volume rendering) is very slow. Segmenting (via MatlabBridge) and registering volumes (SlicerElastix) takes 30 - 60 minutes when previously it would take 3-5 minutes for the same volumes in the same version of Slicer. There is significant lag in updating the surgical tool position on screen making it difficult for the surgeon to interpret the scene.

Any ideas what causes the slowdown over time? Is there a memory leak associated with Slicer or PLUS? In Slicer we typically have 3-4 cropped CT scans loaded (~ 400 x 400 x 400 voxels), and this has not been a problem before. Our machine is also relatively powerful with 32GB RAM and a dedicated NVIDIA GPU.

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [October 17, 2021, 1:24pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/2 "2021-10-17T13:24:16Z")

</div>

First thing I would try is to upgrade Slicer to the Preview version.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [October 17, 2021, 2:25pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/3 "2021-10-17T14:25:38Z")

</div>

I’d guess there’s either a memory leak or that there are data or observers being added to the scene each frame and not cleared up.

I agree with @rbumm that the easiest thing to try is checking if it’s already fixed in the preview.

Second suggestion would be to attach a profiler to see where Slicer is spending time and how that changes over time. I’d suggest Activity Monitor on mac, perf for linux, or Very Sleepy for windows. Sometimes it helps to try different platforms for profiling even if you are deploying on only one (you may learn different things on different platforms).

Finally I’d strongly recommend you develop a SelfTest that emulates your real-world use case as closely as possible, e.g. by generating synthetic tracker data or replaying recorded data. You can run the test over night or with various options turned on or off to home in on what leads to the slowdown.

Fortunately with your software components (Slicer, PLUS, etc) you have total visibility and control of the software so there’s no reason you shouldn’t be able to identify and fix whatever is happening. If it’s something in one of the Slicer or PLUS execution paths please do let the relevant maintainers know so it can be fixed for others.

---

<div class="post-metadata">

### Author: ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)
#### Post date: [October 19, 2021, 6:07am UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/4 "2021-10-19T06:07:40Z")

</div>

@Prashant_Pandey can you please update this thread once you find what’s causing the slow down? This info could be very valuable for other community members

---

<div class="post-metadata">

### Author: ![Prashant\_Pandey](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@Prashant\_Pandey](https://discourse.slicer.org/u/Prashant_Pandey)
#### Post date: [October 19, 2021, 3:15pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/5 "2021-10-19T15:15:12Z")

</div>

Thanks for all the advice. I will check each of these to see what the issue is.

> [@pieper](#):
>
> there are data or observers being added to the scene each frame and not cleared up.

How do I check if this is what is happening? I do add observers during navigation and I have written code to clean them up too, but I am not sure if the clean up is being done correctly.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [October 19, 2021, 5:00pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/6 "2021-10-19T17:00:29Z")

</div>

@pll_llq it could be useful if you could do independent testing - run your navigation system for a few hours and see if you see any performance degradation.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [October 19, 2021, 6:17pm UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/7 "2021-10-19T18:17:45Z")

</div>

> [@Prashant\_Pandey](#):
>
> How do I check if this is what is happening? I do add observers during navigation and I have written code to clean them up too, but I am not sure if the clean up is being done correctly.

One fairly easy way to get a sense of what’s going on is to pause the debugger repeatedly and look at the stack traces to see where the code is spending its time. This is a manual version of statistical sampling that is actually very powerful to see where the application is spending time. If you see a lot of time spent in callback code then probably you have too many observers.

If you are adding observers you can just use `getNode` and `print(node)` to see if the list of observers is getting longer over time.

---

<div class="post-metadata">

### Author: ![Prashant\_Pandey](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@Prashant\_Pandey](https://discourse.slicer.org/u/Prashant_Pandey)
#### Post date: [April 20, 2022, 4:04am UTC](https://discourse.slicer.org/t/slicer-becomes-slower-over-time-during-surgical-navigation-cases/20176/8 "2022-04-20T04:04:09Z")

</div>

Just an update after a few months - I narrowed this issue down to the PLUS servers (one for acquisition and one for processing as suggested [here](http://perk-software.cs.queensu.ca/plus/doc/nightly/user/AlgorithmVolumeReconstruction.html#:~:text=Use%20a%2064%2Dbit%20release.%20If%20some%20devices%20are%20only%20supported%20in%2032%2Dbit%20releases%20then%20run%20two%20instances%20of%20PlusServer.) I found stopping the servers helped speed computational intense steps in Slicer such as for registration.
