Page 1 of 1
IKTool Run Memory Leak Python API
Posted: Wed Jun 01, 2022 7:58 am
by felix.lefebvre
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
Re: IKTool Run Memory Leak Python API
Posted: Wed Jun 01, 2022 9:29 am
by aymanh
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
Re: IKTool Run Memory Leak Python API
Posted: Thu Jun 02, 2022 8:41 am
by felix.lefebvre
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.
Re: IKTool Run Memory Leak Python API
Posted: Thu Jun 02, 2022 11:09 am
by aymanh
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
Re: IKTool Run Memory Leak Python API
Posted: Wed Jun 08, 2022 5:42 am
by felix.lefebvre
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
Re: IKTool Run Memory Leak Python API
Posted: Wed Jun 08, 2022 2:05 pm
by aymanh
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
Re: IKTool Run Memory Leak Python API
Posted: Mon Jun 13, 2022 2:12 am
by felix.lefebvre
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
Re: IKTool Run Memory Leak Python API
Posted: Mon Jun 13, 2022 9:21 am
by aymanh
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