Memory Leaks of underlying Physics Engine?


#1

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


#2

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


#3

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


#4

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


#5

@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 -.-


#6

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


#7

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.