Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the window is minimized (hidden), the MeshArray causes a memory leak. #90017

Closed
MizunagiKB opened this issue Mar 29, 2024 · 2 comments · Fixed by #100257
Closed

When the window is minimized (hidden), the MeshArray causes a memory leak. #90017

MizunagiKB opened this issue Mar 29, 2024 · 2 comments · Fixed by #100257

Comments

@MizunagiKB
Copy link

Tested versions

  • 4.2.stable

System information

Godot v4.2.stable - macOS 14.3.1 - Vulkan (Forward+) - integrated Apple M2 Max - Apple M2 Max (12 Threads)

Issue description

Dynamically generated mesh instances are discarded when they become unnecessary.
However, when the window is minimized, the deletion does not occur and continues to consume memory.
The allocated memory is released when the window is restored, but it can cause a crash in some cases.

This can be reproduced with the following code:

extends Node2D


func _process(_delta):
    var ary: Array = []
    ary.resize(Mesh.ARRAY_MAX)
    ary[Mesh.ARRAY_VERTEX] = PackedVector3Array([Vector3(0, 0, 0)])

    var ary_mesh: ArrayMesh = ArrayMesh.new()
    ary_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_POINTS, ary)

mleak_mesh_array

This issue was discovered during the investigation of the following issue:
#89651

Steps to reproduce

To reproduce this issue, execute the mleak_mesh_array.tscn file included in the attached project.

While the application is running, open the Debugger/Monitors in the Editor and pay attention to the value of Memory/Static.

This value will gradually increase while the application being debugged is minimized.
When the application is restored from minimization, the increased memory is released.

Minimal reproduction project (MRP)

mleak_mesh_array.zip

@MizunagiKB
Copy link
Author

I have conducted additional research on this issue.

Windows

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3623) - Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 Threads)

When the window is minimized -> Memory is not released
When hidden by other windows -> Normal operation

macOS

Godot v4.2.stable - macOS 14.3.1 - Vulkan (Forward+) - integrated Apple M2 Max - Apple M2 Max (12 Threads)

When the window is minimized -> Memory is not released
When hidden by other windows -> Memory is not released

This issue occurs when the Renderer is set to Forward+ and Mobile, but does not occur when set to Compatibility.

@JekSun97
Copy link
Contributor

I confirm this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants