+1 vote

From the Reference documentation:

References keep an internal reference counter so that they are automatically released when no longer in use, and only then. References therefore do not need to be freed manually with Object.free.

I tested creating 100000 ArrayMesh instances without doing anything with it or even creating references to it. I expected all the objects to be disposed of right away. When I looked in the Debugger Monitors tab, the objects were still there. when I looked at the memory used, it was still considerably higher than compared to running game without creating the 100000 instances. I thought maybe giving it time to get to dispose it would do the trick but that didn’t do anything even after at least 15 minutes.

How should I be disposing ArrayMesh instances to free resources?

Actual C# code used inside a _Ready() method:

for(int i = 0; i < 100000; i++)
    new ArrayMesh();
in Engine by (13 points)

I don't know much about ArrayMeshes. Maybe it has to go out of scope before the array is freed?

Try storing them to an array and calling "free" function:

https://docs.godotengine.org/en/3.1/classes/class_object.html#class-object-method-free

Sounds like it might be related to this issue I raised a while ago. My suspicion (based on only little knowledge) is that it's something in the C#<->GDScript interface that's leaking. Trying to manually Free() things doesn't seem to help at all.

1 Answer

0 votes

In my project I use a lot of ArrayMesh.
As I associate them with a MeshInstance (myMeshInstance.mesh = myArrayMesh), when I use "call_deferred("free")" on the parent node, the ArrayMesh is freed to.
Hope that helps ...

by (54 points)
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.

Categories