Page 1 of 1

clear import org.opensim.modeling.* in MATLAB

Posted: Tue May 15, 2018 11:01 am
by hkimpara
Hello,

I found runtime memory of MATLAB increased so much during OpenSim simulation. When I had some simulations until 10 s of problem time, MATLAB occupied RAM more than 10 GB(!). I made clear command for all variables with relatively large arrays. But the situations have not been improved so much.

Now I am thinking about associated memory with org.opensim.modeling.*. Since methods of OpenSim are necessary to handle state variables of OpenSim, I declared "import org.opensim.modeling.*" in several sub-functions of MATLAB. But there is no method to clear org.opensim.modeling.* in sub-functions.
I recognize that "clear import" can make org.opensim.modeling.* clear from MATLAB, but it's valid on command-line only. The ''clear import" is not available in MATLAB function or script.

Is there any ideas or methods to clear org.opensim.modeling.* from MATLAB sub-functions? Is it thing, only Mathworks can solve?


Thank you,
Hide

Re: clear import org.opensim.modeling.* in MATLAB

Posted: Tue May 15, 2018 11:54 am
by chrisdembia
There is nothing to clear with `import org.opensim.modeling.*;`. All this line does is allow you to use OpenSim classes without fully qualifying them. That is, this line allows you to type `Model()` instead of `org.opensim.modeling.Model()`. There is no memory allocation from this line.

Re: clear import org.opensim.modeling.* in MATLAB

Posted: Tue May 15, 2018 12:06 pm
by hkimpara
Hi Chris,

Thank you for your prompt responses. I see the clear of org.opensim.modeling.* cannot become any solutions for us. But it's tough to understand why MATLAB uses so much huge runtime RAM memory although any storage for force or bodykinematics were not enabled.
Probably, I may think another solution with accepting this phenomenon.

Thank you, Hide

Re: clear import org.opensim.modeling.* in MATLAB

Posted: Tue May 15, 2018 8:44 pm
by chrisdembia
Try running `java.lang.System.gc()`. Also, make sure you're not holding onto variables that you no longer need. If that doesn't help, then OpenSim might have a memory leak. It would help if you could isolate what is causing the leak.