# Performance issues when switching scenes

**URL:** <https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412>\
**Category:** Questions\
**Created:** [June 4, 2021, 5:58pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412 "2021-06-04T17:58:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![VictorBwD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/victorbwd/32/16203_2.png) [@VictorBwD](https://forum.babylonjs.com/u/VictorBwD)\
**Post date:** [June 4, 2021, 5:58pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412/1 "2021-06-04T17:58:09Z")

</div>

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.

 ![issue](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/a/5a4317aec9c8fd5550a03bca3ec80eac3319a3e9.png)

---

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [June 4, 2021, 6:04pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412/2 "2021-06-04T18:04:27Z")

</div>

Hi VictorBwD,

Does calling [`scene.dispose()`](https://doc.babylonjs.com/typedoc/classes/babylon.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!

---

<div class="post-metadata">

**Author:** ![VictorBwD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/victorbwd/32/16203_2.png) [@VictorBwD](https://forum.babylonjs.com/u/VictorBwD)\
**Post date:** [June 4, 2021, 6:10pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412/3 "2021-06-04T18:10:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [June 4, 2021, 6:40pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412/4 "2021-06-04T18:40:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![VictorBwD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/victorbwd/32/16203_2.png) [@VictorBwD](https://forum.babylonjs.com/u/VictorBwD)\
**Post date:** [June 4, 2021, 7:19pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412/5 "2021-06-04T19:19:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![VictorBwD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/victorbwd/32/16203_2.png) [@VictorBwD](https://forum.babylonjs.com/u/VictorBwD)\
**Post date:** [June 4, 2021, 8:17pm UTC](https://forum.babylonjs.com/t/performance-issues-when-switching-scenes/21412/6 "2021-06-04T20:17:22Z")

</div>

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!
