[SOLVED] PhysicsSpace create and destroy will trigger memory LEAK

Alike question: https://hub.jmonkeyengine.org/t/memory-leak-using-multiple-parallel-physics-spaces-native-bullet/35743

Example Demo code: GitHub - qiunet/Jme3MemoryLeak: Jme3 Memory Leak demo
ENV: MACOS Big sur JDK 8

Run the example code above, The memory in monitor rise up continuious until process be kill by system!
I do not know is it a bug? Or incorrect use!


jme3-bullet is no longer maintained. Please switch to jme3-jbullet, or better yet, Minie.


By the way, I am not sure if it is safe to destroy physics space from a different thread than it is created in.

maybe you should use the app.enqueue(() -> room.destroy()) to make sure it is destroyed from the JME thread.

or else move the physicsSpace.destroy(); code from the stateDetached() into the cleanup() method of the Room app state because cleanup is always executed from the JME thread.

1 Like

It it work, thanks!


Thank you, Maybe it is a cause to leak too!

it work, thanks!

You’re welcome.
And by the way, welcome to the JMonkeyEngine forum!