This is maybe a two part question, one specific to my program and one general to gui programming. Specifically, I have a close function for my main gui figure which saves some values stored inside the global structure to a mat file. To actually close the figure and clear the global variable, I added:
delete(1000); %the figure number
clearvars -global s
to the end of my close_func. This doesn't seem to completely free up all of the memory however as I can see the amount of memory that matlab uses increases when I open and close the gui multiple times. Unless there is something going on in Matlab independent of my program which is causing this.
In addition, if I open the program enough times, I eventually get a bunch of java exceptions and the program no longer works correctly. I then have to close Matlab and restart the program. I am assuming that these issues are related. I have discovered in the matlab help an entry about not using the get and set commands with Java objects as this will cause a memory leak. Is this also the case for normal uicontrol/uipanel etc gui objects? Am I correct when I say that they are also Java based?
Thanks and sorry for the possibly ignorant questions but software programming is not my strong suit. Although it is a lot of fun!