Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Memory leak in Matlab 2012a?
Replies: 6   Last Post: Jan 18, 2013 2:44 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jesper Holm

Posts: 7
Registered: 10/11/12
Re: Memory leak in Matlab 2012a?
Posted: Oct 11, 2012 7:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

[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 24-7) is a bit special use case, but even small leaks "pr figure" will add up over time and eventually crash our MCR

Regards,
Jesper



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.