GUI memory management guidata
古いコメントを表示
Hi all,
I'm struggling with memory management in a GUI created with guide. My MATLAB version is R2014b.
I use guidata to store data in the handles structure to pass large structures (>1 GB) from one function to another inside my GUI.
Inside a Callback function (of a pushbutton), I would like to erase some of those large structures saved in the handles of guidata and create new ones. However, I cannot seem to delete those structures in the function itself. I added the following code in the function:
handles = guidata(hObject);
handles = rmfield(handles, 'my_variable');
guidata(hObject, handles);
But inside the function, the memory is not cleared. I assume it is because the function in which I call this code has hObject and handles as input parameters (it's a callback function...) The "pack" command also has no effect. However, if I debug on these lines and then during function execution quit debugging (so the function stops abruptly), the memory is cleared and my GUI is still open.
So how can I "reset" this guidata while executing a (Callback) function?
I noticed others were struggling with this too, but did not find a solution; e.g. here: https://nl.mathworks.com/matlabcentral/newsreader/view_thread/297824 (last 3 posts)
Thanks in advance! Vincent
Update From Sven's answer in this topic, I assume that after a Callbackfunction is called, the input parameters are actually a copy of the guihandles. So during the Callbackfunction's execution, the same copy is being stored in guihandles. That explains why the memory stays occupied. So how can I obviate that such copy is being made (or remove the variables in the copy as well)?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!