Closed sebastiankupp closed 1 year ago
Hello, can you share with me your memory loop-test? I am not sure it is safe to merge this PR, it is not clear who claims the ownership between python/c++ and who should release the objects added to the scene.
Hi, here is the minimal test code that successively increases RAM usage
import pyphysx
while True:
scene = pyphysx.Scene()
print('eating RAM...')
del scene
Currently objects are never deleted until the Physics singleton is destroyed at the end of the program. This is a big problem and there has to be some mechanism for releasing PyPhysX objects. As far as I know c++ PhysX objects have an internal reference counter so that objects get released when no one holds a reference to it. Thus calling release in the destructor (and decresing the ref counter) of the Python classes seems to be valid to me.
I did some testing and after I checkout your branch, it broke 01_free_fall.py
example with the error Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
. Did you observe the same issue?
Hey, I tried to replicate your error and ran 01_free_fall.py with the destructors included. Unfortunately I could not replicate the same error message. The code runs without issues.
I observed increasing ram usage when creating and destroying scenes within a loop in python. Checking the code I could not find any release calls for the cpp PhysX objects that were created within the respective classes. Afterwards the Memory usage for my loop-test looked alright.
Please check if these changes make any sense and work in the context of having multiple python references to the same PyPhysx objects.