-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling viewer.setImage() multiple times can cause memory leak #711
Comments
Your on the right tract. Other likely memory leak sources:
|
Hi Paul, |
Hello Tinanuaa, Nice workaround! In the weeds =) So slow framerate when you switch out the image? Before the switch, when it has the smaller image pyramid to use, does the rendering ever switch down to the highest resolution image/pyramid and you notice slow framerate there? There is a dropdown box with a number showing the current pyramid, highest resolution is 0. If the framerate is low becuase the image is to large, perhaps you can use the downscaling method in |
Hi Paul, Sorry for my late reply, I was distracted to another project. So when I updated the pyramid, I just put in the highest resolution, with only one scale( because for our images, it's always 2D and the maximum is 2560 * 2160 uint16 pixels, it won't be too large) and I notice the slow down happen when I was playing with some test images with the size of 256 * 256 uint8 pixels. I tried to just call setImage(ndarray) to let itk-vtk-viewer calculate the pyramids, it was almost realtime update. So my guess is it's not the image size slow down the display, it might be somehow the viewer wasn't triggered to update for some of the frames, which make it looks like it's slowing down. Is it possible that updating the image content and call setImage(multiscaleSpatialImage) to put back the initial image container(with new content) might not trigger a rerender? This is just my guess, I need to play with it more to understand what happened underneath. |
Hi,
I'm using the itk-vtk-viewer in my react app as a component on one page, and it receives live frames from websocket and then display it by setImage(image,"live-frame"). But the browser can crash if the live viewer stayed for around 5 minutes. I notice the memory and CPU usage kept going on frame received. I've tried to use setInterval to set new random images on interval to confirm the memory leak was not caused by websocket, and I tried to pass viewer.getImage("live-frame") to viewer.setImage, and this doesn't cause memory leak either. My guess is each time I pass in the new image as ndarray, which will trigger the toMultiscaleSpatialImage to call itkImageToInMemoryMultiscaleSpatialImage, and this class might somehow cache the previous frames? Or the reference to the previous image is somehow still captured somewhere?
The related code snippet is as below
The text was updated successfully, but these errors were encountered: