Page 1 of 1

Matlab crash using API functions

Posted: Fri Apr 03, 2015 10:00 am
by jewing111
I have a very perplexing problem I am dealing with while trying to run some Matlab Scripts using many of the OpenSim API functions. I am running forward simulations based on the DynamicWalker script using the plant functions. My script has been running fine, but then started crashing matlab after 5-6 executions of the derivatives function in the integrator. After a crash, matlab is now starting up, initializing, and running my "home function" (that executes model set-up before the integration) very slowly. The weird part is that it WILL integrate forward after a crash and when Matlab is running slowly. If I re-start my computer, Matlab will run fast again, but crash. Then I re-boot matlab, its runs slowly, but WILL run the scripts. So the pattern is, crash, re-boot, runs slow but works, re-start computer and it all repeats. This is a problem as simulations that used to take 5-6 hours now will take about 3-4 days. Errors from matlab do not mention any specific lines, but do talk about maxing out a recursion limit, and an access violation.

I am wondering if there is a problem with the communication between opensim and matlab, or a pathdef gone wrong somewhere, but I just don't know what to do about it. I have tried installing several other versions of matlab and they all behave the same way. I have also tried on other computers with similar results.

I am using opensim 3.2 and matlab 2014a,2013b, all 64 bit.

If anyone has any ideas how to troubleshoot this issue, that would be great.

Thanks,

Joe

Re: Matlab crash using API functions

Posted: Mon Apr 06, 2015 9:07 am
by aymanh
Hi Joe,

This sounds like a memory leak that uses the heap causing Matlab to slow down gradually and eventually crash. In previous troubleshooting scenarios using the OpenSim API from Matlab, the issue was resolved by explicitly calling the method

Code: Select all

java.lang.System.gc()
at the end of the derivative function to tell Matlab to release memory that it has has allocated (if not still in use).

I don't think there's a reason to reboot your computer unless there's a background process that you can't kill/stop and it keeps using resources. You may consult Matlab documentation for that since OpenSim doesn't run computations on background threads.

Hope this helps,
-Ayman

Re: Matlab crash using API functions

Posted: Sun Apr 10, 2016 6:39 am
by clarabalust
Dear all,
I think I have a similar problem.
I am modifying (in Matlab) the Simmspline function of the knee joint and then trying to print again the model.
I am able to run the command setFunction but then when I print the model Matlab crashes.
I tried including "java.lang.System.gc()" after I set the function but Matlab still crashes.
I would really appreciate some advice.

Many thanks,
Clara

Re: Matlab crash using API functions

Posted: Sun Apr 10, 2016 7:38 am
by bradh
Clara,

Have you looked at Dominic Farris's prescribeMotionInModel.m? I have used (variations) of it successfully:
https://github.com/opensim-org/opensim- ... nInModel.m

Regards,

Brad

Re: Matlab crash using API functions

Posted: Sun Apr 10, 2016 9:11 am
by jewing111
I would also recommend that script, I am using it to prescribe functions and it seems to work.