Git Product home page Git Product logo

Comments (5)

OverloadedOrama avatar OverloadedOrama commented on May 22, 2024

Hello there. I was expecting objects would be freed automatically on exit_tree(). Or is it just an UndoRedo thing? Also, would there be any difference if I added it in the Main.gd script instead of Global.gd?

from pixelorama.

qarmin avatar qarmin commented on May 22, 2024

All nodes and objects needs to be freed at the end of life.
Only references(child of Reference node like ImageTexture or BoxShape) are counted and are deleted when no one use it.
Nodes should be deleted with queue_free() and objects with free().
You can check which objects and nodes leaks when you opening godot with verbose flag in terminal godot -v or in monitors inside Godot editor(this only show leaked nodes)

Description of exit_tree function from docs - https://docs.godotengine.org/en/latest/classes/class_node.html#class-node-method-exit-tree

Called when the node is about to leave the SceneTree (e.g. upon freeing, scene changing, or after calling remove_child in a script). If the node has children, its _exit_tree callback will be called last, after all its children have left the tree.

That means, that node is out of scene, but it can be deleted or in any moment node can back to scene

from pixelorama.

qarmin avatar qarmin commented on May 22, 2024

Also when I paint something then also Image node is leaking

WARNING: cleanup: ObjectDB Instances still exist!
   At: core/object.cpp:2069.
Leaked instance: UndoRedo:2088
Leaked instance: Image:2135 - Resource name:  Path: 
Orphan StringName: UndoRedo
Orphan StringName: Image
StringName: 2 unclaimed string names at exit.

To get more precise info about node, you can set unique name to all node(I will create issue in Godot repository to automate this)
e.g.

var image : Image.new()
image.name = "Image-Tanks.gd"

from pixelorama.

OverloadedOrama avatar OverloadedOrama commented on May 22, 2024

I implemented your fix for the UndoRedo leak in a4b7fe2. I'm not sure how to handle the Image node leaking though. I tried running godot -v in terminal, and run the project, but I didn't get any "Leaked instance" messages. I'm using Godot 3.1.2

from pixelorama.

qarmin avatar qarmin commented on May 22, 2024

In Pixelorama master branch I can't reproduce leak in Godot 3.1.2 and Godot 3.2 beta 3, so probably the latest commit fixes also this leak.

from pixelorama.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.