All Questions

Community

r
ryanrom5

Is memory automatically managed on the .new() references in Simulation.gd?

Hello,

I noticed we aren't calling free() on _work_system, _power_system, or _tracker like we did with the entity instance()'s in the beginning of this tutorial. Is this because the references here are classes that extend reference and are managed by ARC?

Also, if we called new() on a class that extended node, and didn't add them to the tree, we probably would need to free() those, right?

Thank you


  • Nathan Lovato replied

    Unless you explicitly extend the Object class in Godot, everything extends the Reference class and yes, it is reference counted. It's not exactly automated, it's just that every node or resource extends that Reference class.