MitchEff
MitchEff

Reputation: 1557

React app suddenly is using more than 1 GB of RAM on Chrome

I've been working on an app I'm building, and until now it's had a reasonably small footprint. Today, however, I was looking into why my computer was suddenly running slowly, and I can see the app in Chrome is occupying around 1.2 GB of RAM!

Looking through my commits, I can't really spot anything suspicious. Where should I look when trying to debug enormous memory usage? I'd post code examples, but I can't see anything relevant, really.

Upvotes: 0

Views: 9450

Answers (2)

JustGage
JustGage

Reputation: 1652

Sorry, we might need some more clarification about what you've tried.

It could be a ton of things. Most likely you're storing some sort data from the server or have some sort of memory leak (like adding something to a collection, but never deleting it).

One thing you can do is use the Chrome profiler to see when your memory climbs:

(This can be found in the drawer that open when you push Esc.)

The performance Profiler can be found in the Developer drawer, it might be under the ... of the thing that you push Esc to get to

The "Performance" tab can also be nice if you want to view the memory on pageload (using the 🔄button). Just make sure that memory is checked.

Upvotes: 1

Fred
Fred

Reputation: 3362

To check what React is doing, try go get a snapshot of your app using the React profiler: Introducing the React Profiler

Profiler

For everything else, try checking out the built-in profiler in the Chrome developer tools: Chrome DevTools: JavaScript CPU Profiling in Chrome 58

Those should be two good starting points to look at.

Upvotes: 2

Related Questions