IKTool Run Memory Leak Python API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Félix Lefebvre
Posts: 16
Joined: Fri Oct 05, 2018 5:41 am

IKTool Run Memory Leak Python API

Post by Félix Lefebvre » Wed Jun 01, 2022 7:58 am

Hi,

It appears there is a memory leak when running the IK using the IKTool (in the API but also from Jython in the GUI).
Is it a known issue ? Is there a way to fix this ?

It is a major problem for me as I am trying to run an optimization process using it. Unifortunately the leak seems to add 10Mo of memory at each IK run thus my RAM gets full and the processing end up crashing.

The only way to release memory seems to be restarting the kernel...

Any help would be appreciated.
Thank you,

Felix Lefebvre

Tags:

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

Re: IKTool Run Memory Leak Python API

Post by Ayman Habib » Wed Jun 01, 2022 9:29 am

Hi Felix,

Can you send a code snippet to reproduce the leak? Ideally you can write a C++ equivalent snippet so we know if the issue is specific to the python/java bindings or the underlying C++ layer as the memory management could be different between the environments (garbage collection comes into play).

Best regards,
-Ayman

User avatar
Félix Lefebvre
Posts: 16
Joined: Fri Oct 05, 2018 5:41 am

Re: IKTool Run Memory Leak Python API

Post by Félix Lefebvre » Thu Jun 02, 2022 8:41 am

Please see a very simple example that shows how memory leaks and increase. Release only happens when closing Python (or restarting the kernel).

Code: Select all

import os.path
import opensim as osim

Folder = "C:/Users/felix/Documents/OpenSim/4.3/Code/Python/TestIK/"

scaleModelName	=	os.path.join(Folder, "subject01_simbody.osim");

ikSetupFile		=	os.path.join(Folder,"subject01_Setup_IK.xml");


## Inverse Kinematics tool
# Create the IK tool object from existing xml
ikTool = osim.InverseKinematicsTool(ikSetupFile)
ikTool.set_model_file(scaleModelName)

for i in range(0,100):
    ikTool.run()
    print(i)
I just the following demo files in the folder:
- subject01_Setup_IK.xml
- subject01_simbody.osim
- subject01_walk1.trc

I am not very comfortable with C++ but I will see what I can do.

Thank you for your help.

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

Re: IKTool Run Memory Leak Python API

Post by Ayman Habib » Thu Jun 02, 2022 11:09 am

Thanks much Felix,

That's all we need, no need to translate this to C++ we can do it on our side and we'll make sure it's fixed in the upcoming 4.4 release.

Best regards,
-Ayman

User avatar
Félix Lefebvre
Posts: 16
Joined: Fri Oct 05, 2018 5:41 am

Re: IKTool Run Memory Leak Python API

Post by Félix Lefebvre » Wed Jun 08, 2022 5:42 am

Hi Ayman,

Thank you for taking this into account.

Do you have an estimated deadline for this release ?

So that I know if I can wait or should look for a workaround as a short term solution.

Thank you,
Felix

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

Re: IKTool Run Memory Leak Python API

Post by Ayman Habib » Wed Jun 08, 2022 2:05 pm

Hi Felix,

The issue has been fixed already in development builds and will be available in the beta build of version 4.4 expected within days. You should receive an announcement email if you subscribed to our mailing list earlier. Please let us know when you test it out.

If you want to test the development build please reach out to us on github at https://github.com/opensim-org/opensim-core

Thanks again for reporting,
-Ayman

User avatar
Félix Lefebvre
Posts: 16
Joined: Fri Oct 05, 2018 5:41 am

Re: IKTool Run Memory Leak Python API

Post by Félix Lefebvre » Mon Jun 13, 2022 2:12 am

Hi Ayman,

Just to inform you that I tested the beta 4.4-2022-06-11-bfc372a and it seems solved indeed !

Thank you very much for your reactivity and prompt fixing, it is very much appreciated.

Felix

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

Re: IKTool Run Memory Leak Python API

Post by Ayman Habib » Mon Jun 13, 2022 9:21 am

Thanks for the update and for testing Felix, it sure helps us make the software more robust for the whole user community.

Best regards,
-Ayman

POST REPLY