MATLAB API Destructor

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Maya Madhavan
Posts: 8
Joined: Wed Mar 20, 2013 12:12 pm

MATLAB API Destructor

Post by Maya Madhavan » Mon Jul 08, 2013 1:35 pm

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

User avatar
Ayman Habib
Posts: 2243
Joined: Fri Apr 01, 2005 12:24 pm

Re: MATLAB API Destructor

Post by Ayman Habib » Wed Jul 10, 2013 10:36 am

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

POST REPLY