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
Matlab crash using API functions
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Matlab crash using API functions
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 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
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()
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
- Clara Balust
- Posts: 3
- Joined: Mon Oct 05, 2015 10:21 am
Re: Matlab crash using API functions
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
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
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Matlab crash using API functions
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
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
- Joseph Ewing
- Posts: 7
- Joined: Fri Feb 24, 2012 11:47 am
Re: Matlab crash using API functions
I would also recommend that script, I am using it to prescribe functions and it seems to work.