memory leak 2.1 ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GameVisitor
:warning: Old Version Published before Godot 3 was released.

Hi all, for my game i want to create / erase scenes continuously, so I got inspired by an open source project : 2 taps racer link1 and source code.
I thought the cleanup was perfect, however after running my game for a while, I noticed the memory kept on increasing and eventually (after hours) crashed with the following error :

ERROR: alloc: Method/Function Failed, returning: INVALID_ID
At: core/os/memory_pool_dynamic_static.cpp:81.
Segmentation fault (core dumped)

I am using Godot v 2.1 but 2 taps racer uses v2.2, so i managed to run it in Godot 2.2 and noticed that also it leaked ! (I don’t remember the exact numbers but around 37 MB start to 50.1 MB after 2 hours under linux)

I used the following combinations with no perfect deallocation (memory kept increasing):

  • lastChild.free()
  • lastChild.queue_free()
  • rootDynamicelement.remove_child( lastChild )
  • rootDynamicelement.remove_child( lastChild ) AND lastChild.free()

PS: rootDynamicelement is the element i adding and removing scenes as children.
lastChild is the node (scene) to be removed from the rootDynamicelement

I did check the following links from this forum, but can’t seem to solve my problem:

How force resource to free?
Large number of objects not cleaned up properly

Can anyone shed any light on this ? Is this a known bug in Godot or am i missing
some trivial step for correct cleanup ?

Thx in advance !

PS: I am using purely GDScript as language

So I created a test scene, using the desert one from 2 taps racer, added 2D Panels, and I have no leaks at all… Not sure what was causing it but it certainly was something from my scene setup.

Will update this thread in case i nail it for sure.

GameVisitor | 2017-06-27 18:04