Share 
Follow 
AboutDownloadsDocumentsForumsSource CodeIssuesNews
Date:
2014-03-31 17:17
Priority:
3
State:
Open
Submitted by:
Dimitra Blana (dimitra)
Assigned to:
Ayman Habib (aymanh)
Summary:
Possible memory leak in Coordinate::setValue

Detailed description
I use Matlab to access the Opensim API (Matlab R2013a (32-bit) and Opensim 3.2 (32-bit)).

When I repeatedly call the function:
Coordinate::setValue (with the flag to enforce constraints=true)
...Matlab freezes with an "out of memory" message and the attached log file.

To make sure there is nothing wrong with a specific set of coordinate values that makes it impossible to assemble the model, I ran a test with just a loop that repeatedly sets one of the coordinates to the default value (zero) - it still gives the same error.

I do not get any errors if I set the flag to enforce constraints=false.

Test script:

CoordSet = Mod.getCoordinateSet;
currentDof = CoordSet.get(2);
for istep = 1:10000
currentDof.setValue(state,0,1);
end

Add A Comment: Notepad

Message  ↓
Date: 2014-04-08 21:23
Sender: Ayman Habib

Leak has been found and plugged. Will be in the next release. Thanks for reporting.

-Ayman

Date: 2014-04-07 21:55
Sender: Ayman Habib

Thanks Dimitra,

I was able to reproduce the bug. indeed. I'm looking into it now.

Thanks for reporting.
-Ayman

Date: 2014-04-06 14:02
Sender: Dimitra Blana

Hello,

I've attached the model (hand_ASL.osim) as well as a GUI
script I wrote to try this outside Matlab. I get an error in
the GUI as well:

Jython Interactive Console
>>> Traceback (most recent call last):
File
"C:/Research/hand/model/setCoordinate_with_constraints.py",
line 9, in <module>
currentDof.setValue(state,0,1);
at
org.opensim.modeling.opensimModelJNI.Coordinate_setValue__SWI
G_0(Native Method)
at
org.opensim.modeling.Coordinate.setValue(Coordinate.java:389)
at
sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

java.lang.RuntimeException: java.lang.RuntimeException: bad
allocation

Thank you for your help!

Date: 2014-03-31 17:44
Sender: Ayman Habib

Hi,

Can you please attach the model? The issue is likely model specific and happens when assembly fails so it throws an exception without releasing resources. The message also doesn't make sense since it claims achieving better tolerance but failing!

Assembly error tolerance achieved: 6.93889390390723e-18 required: 1e-09

Please attach the model and any necessary files to reproduce the behavior. It'd also be good to try this as a GUI script to see if the behavior is different since Matlab does it's own memory management that could result in leaks unrelated to our code.

Thanks

Attachments:
Size Name Date By Download
620 bytesout.log2014-03-31 17:17dimitraout.log
282 KiBhand_ASL.osim2014-04-01 07:15dimitrahand_ASL.osim
273 bytessetCoordinate_with_constraints.py2014-04-06 14:02dimitrasetCoordinate_with_constraints.py
Field Old Value Date By
assigned_tonone2014-04-08 21:23aymanh
File Added560: setCoordinate_with_constraints.py2014-04-06 14:02dimitra
File Added558: hand_ASL.osim2014-04-01 07:15dimitra
File Added557: out.log2014-03-31 17:17dimitra
Feedback