2D Platformer Running Extremely Slowly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jackson King

When I play my game it starts pretty smoothly with an FPS around 80, more than enough for a platformer. However, after only a couple of seconds, my game’s FPS doesn’t go above 3 and averages 1.

I can’t provide any specific code related to this issue because I don’t know what part of my code is causing this problem, or if this problem is even being caused by code.

:bust_in_silhouette: Reply From: kozaluss

Maybe some memory leak or unfreed resources? I’ve heard, that resources instantiated manually should also be freed manually. Or maybe the number of objects to process grows all the time and even if they are not present on screen or relevant, they still eat up the processing time?

:bust_in_silhouette: Reply From: avencherus

A few general things to try are to run the game in the Editor, then in the debugging tabs find and run the Profiler and look for offending functions taking too much frame time, otherwise check the Monitors for signs of leaking resources.

Another thing you can do is execute Godot from the command line using the --verbose flag. With a debug build this should give you more details about any orphaned resources / leaked objects on exit.

If all that fails, then you can copy the project, and painfully start chopping off large chunks of it until the problem goes away. That will help narrow the search. Repeat until you land in the right class, then function, etc.