Godot Version
v4.6.1.stable.mono.official [14d19694e]
Question
I’m testing my game on older hardware (i5 8th gen), and there are regular hitches. There is zero doubt that this is GC stopping the game.
I’m creating somewhat relaxed bullet hell game, so there isn’t that much going on, but all of those objects will add up so I’m using object pools for everything (projectiles and enemies) to be sure. So once game is loaded, there isn’t really a lot going on - everything is taken from object pool, and then added back as needed.
I have found out that you should not provide strings directly to some methods, since it will dynamically create StringName or NodePath - and that needs to be cleaned up later.
For example:
Godot.Input.IsActionJustPressed("dodge");
I have seen it being discussed, has it been fixed in newer versions? If it didn’t, it would be my prime suspect for GC issues.
Did you run the profiler?
1 Like
I did but it’s kind of annoying to use. You can’t zoom in a lot, and it’s hard to select specific frames, you need to manually choose them.
Once game is loaded and the spike for first few frames is gone, frame time is around 8 ms, which seems tolerable. But there are spikes, for example one hitch created spike to 30 ms. This delay is enough for player to notice.
What did the profiler say was the culprit for the 30 ms spike?
1 Like
I don’t know if I’m reading this correctly:
- Frame Time 29.54 ms
- Physics Time 1.48 ms
- Process Time 28.05 ms
In average frame Physics Time is 0 and Process Time roughly equal to Frame Time (7-8 ms).
Edit
I’ve also checked monitors, there is definitely spike in Process Time when hitch occurs.
I assume you are using csharp.. the docs have this to say:
The profiler does not currently support C# scripts. C# scripts can be profiled using JetBrains Rider and JetBrains dotTrace with the Godot support plugin.
so if the issue is in your script, I guess you won’t see it 
1 Like
When I last checked JetBrains had only paid products, and they aren’t exactly cheap in my location. Things might have changed though.
Edit
I have replaced every string with StringName in places where it’s used often (pretty much only _Process) and it doesn’t seem to improve things. So it was either fixed, or it’s not source of the problem for me.
I will look into alternative tools for tracking GC.
I don’t think DotTrace is included in that. I also hope to put the game on Steam one day, and this probably counts as commercial use.
Edit
I think dotnet-trace should do the trick, but it has issues when you try to profile process that already runs. I will have to export the project to get an executable, but I will try that tomorrow. But I definitely should get myself jetbrains license in the future.