0 votes

I'm have a problem with my game keeps increasing in memory usage, so i had to take actions to fix that

I try to free an object once it passes certain cordinates:

if get_pos().x >= 750 or get_pos().x <= -10:
     free()

i used a timer to instance this object in the main game scene every time the timer runs out but when the object fulfills the condition of the x cordinate reaching 750 or above (or -10 and below), instead of just the object being freed, the whole game just closes without an error

in Engine by (116 points)
retagged by

Try queue_free() instead of free(). The former waits until it's safe (more or less) to remove the node.

I tried that, but it doesn't seem to help free up memory, as the timer spawns new objects, the memory usage just increases and never reduces

Are you using Godot 2 or Godot 3? If you are using Godot 3, try using just position rather than get_pos(). I am not sure if get_pos() exists or is deprecated in Godot 3 and it might be the problem.

I'm using Godot 2

then, try to find a node which is created but not added to scene.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.