Page 1 of 1

Matlab Scripting: "RRATool" Memory Leak?

Posted: Sat Apr 06, 2013 4:49 pm
by sdriutta
Hello,

I'm able to use Matlab scripting (on both 2012a and 2013a) to successfully run RRA on a model. However, each time I execute rraTool.run(); in Matlab, the physical memory usage of Matlab increases. I'm using this command in a loop, and after about 20 iterations, I run out of physical memory and the program freezes. My physical memory monitor shows a uniform, incremental increase in memory usage.

I've tried a variety of memory clearing techniques (clear java, clear all, clear classes, etc) but have not been able to stop the memory usage from increasing during each iteration. Closing Matlab frees the memory. I've heard that using handles on Java objects may prevent memory leaks in Matlab, but that didn't seem to work for me. I'm not sure if I was implementing the handles correctly however.

I was interested in knowing if there is a way to prevent the memory usage from increasing with each iteration.

Thanks,

Stephen

Re: Matlab Scripting: "RRATool" Memory Leak?

Posted: Mon Apr 08, 2013 9:19 am
by aymanh
Hi Stephen,

We found some memory leaks and fixed them. The fixes will be in the next release but it's hard to tell if that's what you're running into or not since Java uses garbage collection which is easier on the client side but opens the door for other problems. For example, the garbage collector will not release resources if you're holding a reference to them even if you do not intend to use these references in the future. You maybe able to get away with writing your configuration to a file and use the rra executable (instead of running inside Matlab). It's a little more cumbersome but will allow you to get around any memory issues internal to RRA since resources are released on exit.

Hope this helps,
-Ayman

Re: Matlab Scripting: "RRATool" Memory Leak?

Posted: Tue Apr 09, 2013 9:40 am
by sdriutta
Hi Ayman,

Running the RRA executable in my loop prevents the memory usage increase. Thanks for the tip with that.

I'm planning on continuing to use the executables with my loops, but just to follow up with the previous issue: My memory usage was increasing about 30mb for each iteration. You mentioned that a memory leak issue was corrected, but the 30mb increase seems to be too large to be caused by that. I did try setting the model and rraTool objects to null (in Matlab I used [], and NaN) to remove the references so they could be cleaned by the garbage collector, but that didn't change the results. I'll continue trying different approaches with this to see if I can get it figured out.

Thanks again!

Stephen

Re: Matlab Scripting: "RRATool" Memory Leak?

Posted: Thu May 08, 2014 9:26 am
by mengxjchina
Hi,

I am running the Static Optimization and also meet this problem. Could you please tell whether you have suggestions how to deal with this problem?

Thanks,
Jack