Performance issues when switching scenes

Hi, how are you?

So, i have tree scenes: Lobby, tecno room and products. When I click to go to another scene it looks like everything that was in the previous scene is still loaded. The RAM go to 5,5gb only for Google Chrome.

This can cause the system to crash. I don’t find a solution on the net so I decided to post it here to see if anyone has a solution.
Edit: I’m using Nextjs.

Hi VictorBwD,

Does calling scene.dispose() on the scenes you want to unload when you navigate away from them address the issue? If it doesn’t, or if you were already doing that and the problem is something else, can you share a link to a Playground (or other site we can access) that shows the issue? Thanks!

I found something related to this scene.dispose(). I tried to use it and it didn’t work. Maybe I put it in some wrong function…

As for the playground, I don’t think I can explain it there.

Okay. It’s going to be difficult to guess what might be going on without a repro we can look at. The typical way to unload a scene’s resources (in my understanding) is to call scene.dispose(), so if that’s not working for your scenario, I think an accessible repro is going to be especially important in determining what’s going on. If you can’t make a Playground, can you host your work-in-progress site somewhere we can inspect it?

Is complicated because is private by the company, i’m not allowed to do this.

What I need to do is when I click on the change scene button to unload the scene I was in. I will try to do this with scene.dispose() once again.

Well, we got it here. The problem was the Router from Next. We replaced it with href and it worked just fine.

Thank you for the support!

3 Likes