Page 1 of 1

MATLAB API Destructor

Posted: Mon Jul 08, 2013 1:35 pm
by mm828
I am trying to write a MATLAB script which runs 100 trials of CMC and Forward Dynamics, but the script stops after the 13th trial with a RuntimeException: bad allocation error. Is this because of running out of memory for Java objects? I am trying to put a destructor command for each model after a trial is finished, but using ~Model() in MATLAB, which was listed in Doxygen as the destructor returns the error

Undefined function 'not' for input arguments of type
'org.opensim.modeling.Model'.

I would appreciate any input on how to avoid the memory issue in the first place or use the destructor correctly.

Thanks,
Maya

Re: MATLAB API Destructor

Posted: Wed Jul 10, 2013 10:36 am
by aymanh
Hi Maya,

Matlab & Java do garbage collection when objects are not in use so users don't need to delete or free objects on their own. If you can request garbage collection (I don;t know the syntax from Matlab) that could help. If you can do with running the tools as separate processes with the control loop only in Matlab then that should help with freeing resources since all resources/memory is freed when the process is complete.

Finally, we have fixed a lot of memory leaks in version 3.1 (available in beta form) so please try that and let us know if the problem reproduces.

best regards,
-Ayman