nanslice
nanslice copied to clipboard
Memory Leak in Interactive Plot
I'm not sure where to leave this, as I think it might be on the jupyter-widgets side of things. There's currently a memory leak using interactive plots. If I replot the same code several times, the memory usage climbs about ~500MB.
The code I used to test was a basic interactive plot:
import matplotlib
import nanslice.jupyter as ns
%matplotlib widget
base = ns.Layer("D:\Documents\OneDrive\Desktop\sub-1001_ses-S1_task-rest_run-1_bold.nii.gz", cmap='gist_gray')
stat = ns.Layer("D:\Documents\OneDrive\Desktop\midthal_80th_trans.nii.gz", cmap='turbo_r', clim=(0,1.0), mask_threshold=0.95)
ns.three_plane([base, stat], interactive=True)
VSCode baseline starts at:
After the first execution we get:
Which climbs to this after second execution:
I didn't notice initially as my work machine has 32GB of memory, but this is likely much more apparent to those on older/less high-end
Hello,
Thanks for reporting this. I think we should try to narrow down where the problem might be occurring, as the stack is pretty deep! I don't seem to see the same issue, but I am running on Mac, with standard VS Code (not Insiders), so I have a very different environment.
Does the amount of memory consumption grow linearly with the number of replots? Does it plateau at all? I think VS Code now has some debugging options for Notebooks to see variables and memory usage but I've not used them before - if you know of anything like that can you try investigating a bit please?
Thanks!