[SOLVED] Memory Leaks of underlying Physics Engine?

Hey everyone.

I’m currently working on a project, where I am using a LevelBuilder script to build the chosen level. It reads a string from a file, interprets each substring as a level segment and attaches them next to one another. so far so good, the level builder is working great.

But when testing it more extensively and loading one level after another, after a few scene changes I notice uncontrolled behaviour, like not loading the level at all, or only loading it sometimes.

I took a snapshot of the heap, and i noticed a constant increase in the number of btVector3 objects that got created. I was wondering why the memory wasn’t released and assumed it was a mistake in my code. But I created a small sample project, just with a basic cube in both scenes. And after each scene transition, the number of bt-objects increased, even though I don’t keep any references of objects of the other scene.

example scene: Sample Project

Heap Snapshots:

Is this behaviour intended or a bug? Is there a way to release the memory manually? how can i avoid an overflow, if I have to load lots and lots of objects?

Thanks

@will @dave Can you please give us a hint on this one? :disappointed_relieved:

I think @halvves was investigating this. He’s been busy with some other things but maybe he can give his thoughts on this anyway…?

We are still running into memory issues. Ammo is allocating memory, but doesn’t free it on scene changes. @halvves

1 Like

@will @halvves We are currently not able to deliver one of our games to the customer because of physics memory leaks.

Also this thread may be related -.-

1 Like

@moka has been investigating. Perhaps he can provide an update?

1 Like

I have identified some leaks related to entities not being freed properly when using loadSceneHierarchy, indeed.
But need to pinpoint it further, as it is a bit complex and many things are noisy on memory along the way. So looking deeper into it.

1 Like

There is PR coming, that fixes most memory leaks related to ammo.js I could find so far.

And related to scene changing, there is another one, that is leaking, and it if fixed too:

Lets wait when engine is released, look for new Releases: https://github.com/playcanvas/engine/releases

2 Likes

This is now deployed.

4 Likes