[SOLVED] Issue with scenes changes

Solution / Problem Solved:

  • To anyone reading this with problems regarding Lag / Performance dropping after changing scenes, on a game that uses scene swapping a lot.

  • At the time of writting this the problem was found to be the “FlexBox” Extension, it has some sort of memory leak, not deleting data on scene changes. Removing this extension will fix the problem, at least it did in my case.

  • Thanks again to the Devs for being so quick to find it, hope this helps anyone with the same problem!

Hello there!

As my game got bigger i started to notice FPS drop over time as i was play testing, i thought it was fine, just some performance issue on Previewing the game.

But its not.

When the problem got so serious it began to break the game, with the game running so slow it had a hard time updating variables, scene elements breaking, all sorts going wrong, i looked it up to see if anyone else was having the same problem.

What i found was that, there was plenty of people with the same issue, more to exactly the issue everyone is having is this:

  • If your game is heavely dependent on changing scenes frequently, as in using a scene for each room in your game and then changing between them frequently, the game starts to slow down, as if its not deleting the previous scene, keeping something in the background and pileing it up untill the lag is too much.

I have this EXACT issue and this “Memory Leak” bug seems to have been introduced in a GDevelop update, the evidance for this is that some people have tried rolling back to previous versions and that fixes it.

Before anyone goes saying that its probably something user related like “Events” or whatever, just stop, its not, me and other have tested and tried to fix this, it has nothing to do with the user, its PRECISELY A SCENE CHANGING ISSUE, its the scenes that trigger the pile up or “Memory Leak” kind of bug.

MY EVIDANCE for this:

  • I just finished redoing my game to use a single scene.

  • Im using the EXACT same quantaty of objects, the same variables, the same timers, evetything is the same, THE EXACT SAME to be perfectly clear.

  • The ONLY change is that now, instead of changing the scene, i instead delete everything in the scene and then create the new room with external layouts.

  • The game plays the same, uses the same things, everything is the same, i just dont change scenes… and the result? SMOOTH 60 FPS no matter what.

  • I even increased the load by spawning a bunch of objects, still smooth 60FPS, rock solid, unmoving.

  • Its 100% an issue with the act of changing the Scene, something goes wrong when you do it, it tanks your performance like crazy and the more you do it the worse it gets.

  • If you think you dont have this issue and you use lots of scene changes, your wrong, my guess is that your machine is hideing the problem by over speccing the game, but give it time or run it on a slower machine and youll see the FPS drop untill it breaks.

I did all sorts of testing, i bullet proofed the scene changes with preload, load, stop scene, all sorts of trial and error situations, monitored performance multiple times on the debugger troughout the play test nothing fixed it because its an INTERNAL SOFTWARE FLAW, something broke in an update, thats all, stuff happens, just please stop ignoring it, its silly to be afraid to use more then one scene.



Unfortunately, people with reports on this in the past have never been able to reproduce it (for investigation). It was reported a few years back, and at that point I took the not-a-vania example and run it on an old Windows 7 machine I had at the time, rapidly switching back and forth between the title and the game scene without being able to reproduce it.

If you have it actively reproduceable (as in you have a project that can show it happening 100% of the time), that’ll be useful for the devs to dig into.

To be clear, I’m not asking you to share your game files in this thread (and would recommend against it), but you might need to be ready to provide it to the engine devs if they need it for further investigation, if that’s the only place you can reproduce the issue.

1 Like

If there is a way to help i will.

I think i simple example wont really do it, if the scenes are nearly empty and you have only a few events then it will take ages for the “Memory Leak” to pile up.

I have an actual working game, with monster AI, lots of animations, particles, objects, sounds, lots of checks running in one scene.

Which btw, the amounts of variables and resources im using is not the problem, im still working on my game since its still on the bare bones phase and ever since i changed to using just one scene, no more memory leak, just smooth fps no matter what.

To be a little more exact on what the bugged version of my project contains or is doing.

  • I have a lot of variables, its a platformer RPG with a few equipable items (around 10 atm)

  • Im using External layouts to create the game menus and UI.

  • Im using the some regular behaviours, nothing special, platformer, platform, gamepad, tween, when not on scrren and FlexItem, FlexContainer for the equipment and items UI.

  • Each room is a diferent Scene, each Scene has the same layers and use the same External Events (A single big block), thats linked to a seperate empty scene just for the sake of keeping things clean.

  • My character goes through the room untill it gets to the door, when using the door the scene stops, picks a new random scene, at the beginning of the scene creates all external layouts and events, and the cycle goes on.

  • After clearing 5 rooms you get sent to a main hub, main hub works the same as the other scene changes, creating external layouts and events.

  • after the main hub you change to a scene with a boss, beat the boss and the cycle restarts.

  • Like i said before, i made sure to bullet proof the scene changes and properly test performance and such, nothing made a diference, no changes to the events made any diference.

  • After swapping to using a single scene, same everything, events, objects, global variables, object variables, everything, only diference being i programmed it so that everything in the base layer of the scene gets deleted when changing rooms and the creating the new room using external layouts.

  • The result is that i no longer have performance issues.

  • I still have the bugged version if theres anything youd like me to check or if the devs want me to provide something.

  • THIS IS IMPORTANT, if it really is a memory leak, which feels like thats exactly the issue, you need a proper game, a finished one, running on scene changes and a machine that isnt over specced to see it happen straight away, if you test it on near empty scenes with no timers, AI or anything impactful, then its like doing 0x?, the answer is always 0, or in this case the change is so minimal youll never notice it.

  • The fact that restarting the game, or hitting refresh on the preview clears the lag and restarts the lag cycle more goes to show that theres something that isnt being deleted, some temp files, cache, something is there eating performance…


I think i found something.

While i was cleaning up my events and improving the performance on my game, the new version using only once scene, i noticed something that slipped past me, so i whent back and did some more testing between the two projects, heres what i found:

  • The two projects are identical in terms of performance, as in, before the lag really hits, the performance on the debugger is alocated in the same way.

  • The project that uses scene changes begins to pile up Lag and the “ms” starts going up evenly on everything.


  • On the “Callbacks and extensions (pre-events)”, in the project that uses just one scene, the performance is always at 0ms, all the times that i run the debugger, it always returns 0ms

  • On the project that uses scene changes, “Callbacks…” starts out at 0ms on the first scene and then with each scene change it starts pileing up the “ms”, slowly at first and then ramping up the more i change scenes.

  • For reference, on the project with scene changes, “Callbacks…” starts at 0ms and the actual “Events” start at around 3.40ms. After the lag starts hitting hard, “Callbacks…” sits at around 40ms while “Events” sits at 13ms.

“Callbacks…” seems to be the smoking gun, everything else starts lagging based on the lag of “Callbacks…”, and also being the biggest offender of Lag by a long mile by the end.

I dont know what this means exactly or if its even relevant but its what i manage to find.

Its got to be it, since its literally the only diference between the two projects, on the single scene project the “Callbacks…” ms is always at 0 no matter how long i play and the performance is always good.

To be clear,. im still using the same everything, global variables, events, behaviours, etc… its all the same, thats the only smoking gun that i found.

Hope it helps, if theres anything i can do let me know!

1 Like

Wait… Really? So it creates new scenes but dosent delete old ones?! Is this confirmed? If so… the hell, no wonder theres an issue… How is this still a mystery? Just delete scenes that were told to “Stop”, its not like you can go back to them, whats their purpose other then slowing the game down?

Thats so dumb…


This is a false statement. Please don’t confuse the issue.

Global variables are kept in memory, scenes are not.

If scenes are being kept in memory in full that is not by design, especially with recent changes to make it so scene assets are only loaded as they are needed rather than preloading all assets.

1 Like

Oh ok pardon me.only globals are kept,
so scenes are deleted

That makes more sense… but considering the whole “Callback” thing, a “Callback” has to do with variables, as in, calling back prior values.

Do you think it might be an issue with the global variables? Like, its not updating the old ones and instead everytime it updates it creates new ones on top or something like that?

Something is pileing up in memory thats for sure, and with what i found, its 100% triggered on scene changes and callback values.

Anything is possible at this point, but I can’t recreate it in my main game which currently has 129 global variables(inventory, player stats. Room states, minimap discovery) with about 25 scenes (title, options various portions of the game map levels, etc), so I can’t give more context. Also even if it was creating new, they’d have the dame namespace so they’d override anyway.

If a dev does chime in they will need a project that can reproduce it 100% of the time, so if your game can reprpdice it they will likely need to get a copy from you.

Could you try running your main game and keeping track of “Callbacks…” performance on the debugger?

As in, run it once at the start at note the “ms”, then again after a while and again at the end see if its pileing up “ms” even if in small amounts.

I am currently remote so I can’t do any testing, but I’ve flagged what I could to see if someone in the dev group can take a look.

I am no longer a moderator so I can’t guarantee anything, but I’m hopeful the above will be enough info to at least start a deeper dive.

Theres actually more to this…

I have a lot of free time since im a retiree, and iv been working on my game pretty much all day every day, leaving the computer running when eating or taking a break and leaving GDevelop always on…

Im back to thinking its a memory leak, iv noticed performance drops throughout the day as im testing the game, not just on the game but on GDevelop itself…

Now that im tracking fps more closely i began to notice some drops, for example…

  • As soon as i open GDevelop and run my game, it plays at 60 FPS, rock solid, no matter how long i play.

  • After a few hours of developing and testing, as soon as i start the preview, the game is running under 60 FPS, around the 50, going from 45 to 55…

  • Closing and reopening GDevelop bring it back to smooth rock solid 60FPS

I mean… thats a freaking memory leak for crying out loud… its like starting the preview counts as making a scene but closing the preview dosent delete it, keeping things in memory, just like the issue of changing too many scenes…

There is for sure, without a doubt something wrong with the memory on GDevelop, theres something not clearing and pileing up trash.

This is beyond confirmed and should be looked at deeper.

I use all of those, its a complex game, i use tweens, color changes, lights, object variables, timers, scene and object timers, everything really…

But it dosent matter, it should kill all that stuff when changing scenes or closing the preview, theres no reason to keep it in memory.

When you tell something to shut down it should shut down, not do things half way because it leads to things like this.

Okay, dude stop this.

Again, this is incorrect. You are confusing your specific project with a different long running issue.

Please don’t make declarative statements that are unrelated and incorrect.

Show and hide states are not kept between scenes, or even the same scene, when using rhe change scene action. Full Stop.

1 Like

If you use pause and start a new scene, the scene will be kept in memory as is, and a new one will be launched on top of it. Perfect for pause menus, inventories, rooms, etc…
If you do it too much, memory usage will grow - this is by design.

If you use Change the scene, memory usage will stay stable, because the current scene will be unloaded and a new scene launched. We fixed memory leaks for this many months ago now (it was due to text objects not liberating their memory).

If you suspect a bug, create a minimal game, launch it and check that it goes from 100mb to 1G to 2GB to 4GB when you keep pressing a button to change a scene. In this case, you can consider submitting on GitHub so we find the reason for the memory leak :slight_smile: A bug can always happen, but remember to check you’re using Change the scene and not the other action.

1 Like

I’m using change scene and some actions are kept…at least it looks so…
If it’s that normal i’m ok since i know now how to solve it in my game.(and it means negate averything befor a new scene start)
But do it means that the scene is unloaded?

It was idd a text object…
but i restarted everything after Silver told me how to do it so i don’t have the file anymore, i may try to recreate and post on github

EDIT: ok it was binded to a global…Silver is rite they’re not kept… i need to check every damn global befor a scene swap

Please stop this dumb arguing and ruining my work.

Pause and Change Scene are two diferent things, one “pauses” and keep your stuff untill you use return to paused scene and the other STOPS it and suposedly deletes it.

I KNOW THIS, you should too, it says on the tooltip exactly what that does.

On my project i use change scene, im not a morron.

There is a memory leak on changing scenes, not pausing scenes, CHANGING.

I tested it plenty with my project, its like i said, the diference is on the “Callback…” like i already explained.

Please focus on the original point.


Please focus on the original post and what i found, not on clear user issues.

Its not a user issue on my end, iv gone through all the possible things on my end, im using all the right action and conditions, im not pausing scenes, im changing them.

Its like i mentioned before, the diference between the two projects is on the “Callback…” if that helps.

Let me know if theres something else i can do

Ok someone explain this to me…

  • As i was cleaning up more progaming i noticed i left an old condition from when the project used scene changing, the “Scene has finished Preloading” was still active on one of my “fake” scene changes, deleting everything, creating external layout stuff… and it was working, EVEN THO it was a condition check and i DID NOT tell it to preload that specific scene, the check still passed as true and the action happened, thats why i didnt realise that condition was still there.

So… i double checked this whole scene thing again, and…

  • If a scene exists in your project, IT WILL BE PRELOADED at the start of the game no matter what, the action “Preload Scene” means NOTHING, the scenes are ALWAYS being pre loaded.

How do i notice this? Easy testing for anyone who wants to check it out.

All i did was make a block with the conditions: If key is pressed, If scene has finished preloading, Trigger once, and then the action “Change Scene”.,

It will work, even tho you DID NOT tell it to preload the specific scene, i tried it with all the unused scenes, and they were ALL PRE LOADED.

I also did the exact same thing but instead of If the scene has finished preloading, i used “If the scene exists”, and it was checked as true, the action happened, changing the scene.

So… again, the hell? Why are all scenes preloaded even tho i never told it to load them or change to them?

Everything is already preloaded in the background, it all exists there, you telling me there NO CHANCE of a pileup in memory? even tho its loading stuff you dont want it to load?

I also keep notecing performance drops when opening GDevelop for the first time, after a little while and restarting the software it all goes smooth again.

Please have a better look at this, i love GDevelop, im not just knocking it, i want to help make it work properly.

Let me know if i can help

Another little update…

All Scenes Pre Load at the Start of ANY Scene without being told to do so.

EVERY time you change a Scene, ALL scene Pre Load.

I made a condition, If the specific scene finished pre loading, trigger once, with the action Play a sound.

At the start of the game the sound rings, evety time the scene changes, the sound rings again…

You sure this had nothing to do with it? Why are all scenes being loaded in the back every time you change a scene? thats silly and clearly not right.

I get you wanted to make the game load slowly in the back to make loading faster and all, but this is counter productive, its loading ALL SCENES, EVERY TIME A SCENE CHANGES.

Clear enough? Its easy testing, just do what i did.

EDIT: You know all things considered, this means that RMDB was actually right in saying GDevelop dosent delete scenes and keeps stuff in memory, even tho his issue was more user related, this is actually true if scenes are always being preloaded and kepts in the background, which is super silly…