|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
lowpolygon |
Just suddenly occurs to me, if I instance an object without add it as a child to a node
what happens to that instanced object after that function finished running ?
|
|
|
|
Reply From: |
Dlean Jeans |
If it’s stored as a local variable then it will be gone.
If stored as a class property then it will remain there still.
“Gone”, as in “memory leak”
Zylann | 2019-07-03 12:37
Yep, you’re right, “gone” as references but dozens of MBs can be leaked per second in _process
.
Dlean Jeans | 2019-07-03 14:54
|
|
|
|
Reply From: |
hilfazer |
Nothing will happen, Object will continue to exist causing a memory leak.
SceneTree takes care of lifetime of Nodes that are inside it. Nodes outside of tree need to be free()
d manually.
There is an object that is reference counted, thus have automatic memory management. It’s Reference.
Node doesn’t inherit Reference.