Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | HardFire1 |
Hello, please help. When I turn between scenes, I have them change. But if I do it several times, then RAM memory gets clogged up with me. Can I somehow release her? Please give examples.
I don’t entirely know what your asking, let alone what the problem is. But I would recommend in not putting change_scene()
in the _physics_process()
function, as that function could be executed many times in a second.
Also, the next time you ask a question, please paste your code instead of taking a screenshot.
Ertain | 2019-04-21 23:23
Sorry for my English. I’m trying to say that when the game is changing quickly the same scenes (the player goes into the test location), then the RAM consumption starts to grow. And after the character has stopped the memory does not decline. Just enough is only 20 transitions to increase memory consumption by at least 2 mb and I think that for such a small game like mine this is very critical. Here is the code.
*MAP JUMPER*
extends Area2D
export(String, FILE, "*.tscn") var world_scene
func _on_Map_jump_body_entered(body):
if body.name == "Player":
var Global = get_node("/root/Global")
if Global.Game["Player"]["Entered"] == 0:
Global.Game["Player"]["Entered"] = 1
else:
Global.Game["Player"]["Entered"] = 0
var root = get_tree().get_root()
var id = root.get_child_count()-1
root.get_child(id).queue_free()
get_tree().change_scene(world_scene)
With approximately 10 transitions, memory consumption increased by 2 mb
HardFire1 | 2019-04-22 01:34
What do you exactly mean by “transitions”? Shouldn’t your character move to the test area once, and the previous scene freed from memory? As for an increase of 2MBs of RAM, well, that could be due to the overhead that you may receive from an interpreted (i.e. scripting) language.
Ertain | 2019-04-22 07:37