GUI (GUIDE) with images leaking memory

Matlab 2018b with GUIDE running on Win 7.
I am programming a GUI that displays small image "thumbnails" from a directory in an axes object. The user selects an image, then presses a button to load said image into a larger axes object for analyses. I am saving the image data and other variables to a series of structures, which I am storing in the main figure using appdata.
My problem is that the GUI is leaking memory. While sitting dormant for 15 minutes, my computer's memory usage increases from 10 GB to 22 GB. The memory usage increases further when I use the GUI -- up to 30GB. At this point, Matlab seems to stall, and I often must close Matlab from the Windows Task Manager to recover the memory. If I am able to close the GUI figure, the memory is NOT returned.
I have researched this issue extensively, and have tried the suggested fixes ("pack" command, "Manage GUI memory" and "Resolve 'Out of Memory' Errors" in the documentation, storing appdata to the Desktop, restarting the computer, etc, etc). None have worked. I don't mind saying that I am very frustrated. Has anyone else had this problem, and how did you fix it?

8 commentaires

Rik
Rik le 18 Mar 2019
I had something like this with the code of a co-worker. It only seemed to happen on a very old version, where it was much less bother to simply build in a restart sequence instead of fixing the leak. With R2018b that should not be the case.
So to your problem: is it possible to share your code? Have you tried to reduce the code down to the smallest piece that would still cause the problem? Is there a reason why you are using GUIDE outside of the designing stage?
Walter Roberson
Walter Roberson le 18 Mar 2019
Is it possible that you have "hold on" and that new images are being displayed on top of the old without deleting the old ones? Or is it possible that you are creating a lot of figures without deleting the old ones?
CAM
CAM le 18 Mar 2019
Thank you both for your replies.
Rik: I am using GUIDE for this (inherited) application, which uses guidata and set/getappdata. I will look into paring down the code to see where the leak occurs.
Walter: I toggle off any holds once complete. I will look into adding a cla command when updating image data on the axes object. However, I am still puzzled as to why memory leaks when the application sits dormant.
CAM
CAM le 19 Mar 2019
Walter: The cla command did not seem to help. I even changed my original code that steps through the frames of a "movie" file (2-3 seconds long) -- used to call "imshow" with each frame, now I update CData in the image object -- but the problem persists.
The bigger frustration is the leaking memory (and intermittent high CPU usage) when there is no interaction with the GUI. Do I need to reinstall Matlab?
Walter Roberson
Walter Roberson le 19 Mar 2019
Nothing is coming to mind at the moment .
Do you happen to have any timers running, or any audio input, or any camera input, or any data acquisition sessions ?
CAM
CAM le 19 Mar 2019
No timers, inputs nor DAQ sessions.
Andrew Stevens
Andrew Stevens le 14 Oct 2020
Did you ever figure this out? I am having exactly the same problem with a non-GUIDE GUI. The memory just goes up when the GUI is idle and really chews up memory as I interact with the GUI. I am using R2020a and am also looking at image data (using imagesc function) in the GUI. Looking through the guidata, I cannot find any variables that can account for the memory usage.
CAM
CAM le 14 Oct 2020
I actually never did figure out the source of the leaking memory. It seemed to go away when I upgraded to 2019b late last year (2019). I have not noticed the same problem since. But (full disclosure) I did receive a new workstation (running Win10 & Matlab 2019b) in March 2020, so I am sure having a "clean" machine has helped.
Wish I could be of more help. Thank you for following up.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Produits

Version

R2018b

Question posée :

CAM
le 18 Mar 2019

Commenté :

CAM
le 14 Oct 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by