opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
790 stars 317 forks source link

Memory leak in StaticOptimization and in InverseDynamics (begin()) #154

Open chrisdembia opened 10 years ago

chrisdembia commented 10 years ago

I was playing around with cppcheck and it reports memory leaks here and here.

aseth1 commented 10 years ago

The InverseDynamics Analysis should be removed or at least hidden. It only remains to serve RRA. RRA should be switched to using the InverseDynamicsSolver. I gave it a go awhile back but it wasn't as straightforward as one would expect. There were something scary there that I blocked out of my mind.

Anyhow the leaks look legit. Let's see- the model's original force set (call it O ) is cloned (call it C). The analyis' _forceSet (call it A) is assigned to a set of CoordinateActuators (also heap allocated). Then it appends clones of all non muscles from C to O. Doesn't that mean O has a double count of the non muscle actuators? In the end A has coordinate actuators but should have model actuators and the coordinate actuators? I truly hope this branch is never actually executed. @aymanhab any ideas what this is supposed to be doing?