Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Memory leak in Matlab 2012a?
Posted:
Oct 11, 2012 7:47 AM


[snip] > > Instead of closing your figures within the loop, try to clf the current figure and reuse the same figure window. This would also be better for performance. Even better, reuse all the internal handles as well (annotations, axes) such that instead of clf you would simply modify their internal properties  this would run much faster and would also remove the leak. > > I suspect that the current memory leak that you see may be due to the fact that Matlab does not properly destroy the figures' resources upon closing, and 20KB per iteration (=per figure) seems about right. > > Yair Altman > http://UndocumentedMatlab.com >
Thank you for the feedback. The example provided is for sure not the most optimal solution  I just tried to keep things simple.
Your idea regarding reusing the internal handles is good and I will definitely consider it. The downside is that we have thousands of lines of Matlab code that would need to be reworked. The task is furthermore complicated by the fact that figures are annotated based on the data so the number of annotations pr figure is not constant. Hmm...
I guess that our scenario (MCR exe running 247) is a bit special use case, but even small leaks "pr figure" will add up over time and eventually crash our MCR
Regards, Jesper



