# Insane ram usage when scrolling around the page

**URL:** <https://discourse.threejs.org/t/insane-ram-usage-when-scrolling-around-the-page/24454>\
**Category:** Questions\
**Tags:** performance\
**Created:** [March 16, 2021, 3:11pm UTC](https://discourse.threejs.org/t/insane-ram-usage-when-scrolling-around-the-page/24454 "2021-03-16T15:11:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Degubi](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/degubi/32/16678_2.png) [@Degubi](https://discourse.threejs.org/u/Degubi)\
**Post date:** [March 16, 2021, 3:11pm UTC](https://discourse.threejs.org/t/insane-ram-usage-when-scrolling-around-the-page/24454/1 "2021-03-16T15:11:26Z")

</div>

Hi all!  
I’ve been trying to figure out why my code’s memory usage is horrible when scrolling the page.  
What I have is a page with a single canvas and multiple cameras & scenes (based on the ‘multiple elements’ example)  
What happens is when I scroll the page the memory usage jumps from a few hundred megabytes to 3-5 gigabytes.

What I tried:

- Switch from render on demand to normal loop rendering. Memory usage was fine when not scrolling, went insane as soon as I started scrolling.

Browsers I tried it in:

- Chrome
- Edge

Repository with code: [GitHub - Degubi/Three-Memory-Demo: ThreeJS demo repo](https://github.com/Degubi/Three-Memory-Demo)  
Demo hosted on Heroku: [https://three-memory-demo.herokuapp.com/](https://three-memory-demo.herokuapp.com/)

‘multiple elements’ example: [three.js examples](https://threejs.org/examples/?q=multiple#webgl_multiple_elements)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [March 16, 2021, 3:36pm UTC](https://discourse.threejs.org/t/insane-ram-usage-when-scrolling-around-the-page/24454/2 "2021-03-16T15:36:21Z")

</div>

The problem is that you are creating for each scene three shadow casting point lights with 1024x1024 shadow maps. I’m afraid this setup does not properly scale.

---

<div class="post-metadata">

**Author:** ![Degubi](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/degubi/32/16678_2.png) [@Degubi](https://discourse.threejs.org/u/Degubi)\
**Post date:** [March 16, 2021, 3:45pm UTC](https://discourse.threejs.org/t/insane-ram-usage-when-scrolling-around-the-page/24454/3 "2021-03-16T15:45:28Z")

</div>

Decreasing the shadow resolution from 1024 to 256 solved it!  
Thank you!
