0 votes

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: INVALIDID
At: core/os/memory
pooldynamicstatic.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

asked Jun 26, 2017 in Engine by GameVisitor (386 points)
edited Jun 27, 2017 by GameVisitor

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.