This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm working on editor plugin. The important code does this: Each time the user clicks on MeshInstance, new Mesh is generated by SurfaceTool and it's set in MeshInstance.set_mesh(). The old resource is no longer in use and should be freed by engine. Quick look at Task Manager showed me that every time I click, 20-80 kB of data is allocated.

I'm sure the MeshInstance.set_mesh() is leaking because if I just generate new mesh and don't set it, no memory is leaking. Is there a way to force old mesh resource to free?

Important part of the code:

var newWireMesh = generateWireframeMesh(meshTool)

The whole script is on Pastebin

in Engine by (836 points)

I fixed the leak. If you do something similar as me, a good practice is to reuse the Mesh. You can pass the old mesh to SurfaceTool.commit(oldMesh). It will create a new surface with your new data. Don't forget to delete your old surface first: oldMesh.surface_remove(0). It's only a bypass tho. The leak is still imminent.

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.