-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Godot leaking massive memory just by itself #82769
Comments
Tested on Windows, doesn't seem to leak after a pretty quick test so could be a MacOS issue. Possibly related to #62507 If you change the renderer to Compatibility (editor button on top right), does the leaking stop or change? When running the project, do the memory stats in bottom panel |
I did a quick test with compability renderer, same result (memory usage starts out lower, but keeps growing regardless). Memory stats in the debugger are steady with both renderers. I will try out the other builds later today and post the results. Edit: Both 4.1.2 and 4.2.dev6 have the same issue macOS |
Tested in 4.2.dev6 on a M2 Pro macOS 13.6 now and I can see the same issue using both Compatibility and Mobile renderer. Memory seems to be leaking at about 0.1MB/sec according to macOS Activity monitor, both from the run project and just the Godot Project manager when you that. If I toggle on the Update continuously editor setting I can see a similar memory increase for the editor, but not if it's disabled. The leak rate also seems to vary with update rate, as it appears to leak quicker at 120fps than 60fps. |
It seems to be macOS bug, leak seem to happen inside the following calls: [NSScreen visibleFrame]
[NSWindow isOnActiveSpace] Both are called every frame, relevant code ( godot/platform/macos/display_server_macos.mm Lines 3564 to 3577 in b931a6e
|
Stack traces for the leaks: __CFAllocateObject
__NSArrayM_new
+[NSArray array]
-[NSConcreteMapTable allValues]
+[_NSFullScreenSpace fullScreenSpaces]
+[_NSFullScreenSpace visibleFullScreenSpaces]
+[_NSFullScreenSpace visibleFullScreenSpaceOnScreen:]
-[NSScreen _hasMenuBar:]
-[NSScreen _layoutMenuBarHeight]
-[NSScreen _layoutFrame]
-[NSScreen visibleFrame]
DisplayServerMacOS::window_get_mode(int) const __CFAllocateObject
__NSSingleObjectArrayI_new
+[NSArray arrayWithObjects:count:]
-[NSWindow _isInSomeVisibleSpace]
-[NSWindow isOnActiveSpace]
DisplayServerMacOS::window_can_draw(int) const |
Perhaps an option could be to use NSWindows visible and occlusionState properties instead of using the screen visibleFrame and isOnActiveSpace? They seem like a good fit to determine if the window can be drawn to, and might also let us catch some other issues like #64708 |
This seems to be working, not sure if both We probably can cache the value in the |
Yes, it seems |
I am still experiencing this memory leak, using Compatability on Macbook Pro: Exporting the game had the same issue. But when I switched to Forward+ it resolved and now only uses 1gb of memory according to activity I'm on: monitor.v4.2.stable.official [46dc277] |
This is not related leak, ANGLE Compatibility backend is broken and causing it, ANGLE was disabled in 4.2.1. If you want to use Compatibility renderer in 4.2 (why?), go to the |
Godot version
4.1.1 stable
System information
macOS Montery 12.5.1, 16GB RAM, Forward+ Renderer
Issue description
When running a project from godot (pressing the play button), the new window will just keep leaking memory, regardless of project size.
The Tests:
I set up a new project, added a scene and tested the following:
While running the tests I didn't do anything else, just kept the Godot window open in the background.
The Results:
I tested every configuration for at least 2 hours, some longer (except for the last one, ran out of time)
As you can see even just an empty scene in an empty project will keep growing in memory usage, my guess is indefinetly. Notably the last test (with an empty scene, containing just an empty Node) grew the fastest. Likewise the tests with 20 Node2Ds yielded similar resuts, regardless of processing being turned on or of. This leads me to believe that godot itself is leaking memory, not the nodes.
I will also attach all screenshots I took during those tests, showing my activity monitor (which is apples task manager). You can see how the memory usage changed over time. I tried to take a screenshot about every 30 minutes.
Single Node:
Single Node2D:
20 Node2Ds:
20 Node2Ds with processing turned off:
Single Node (again after all other tests)
Steps to reproduce
Create an empty project. Create an empty scene. Run that project. Observe memory usage growing.
Minimal reproduction project
empty-game.zip
The text was updated successfully, but these errors were encountered: