Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this js heap graph worrying? How can I fix it?

I have recorded the performances of an angular 4.4 app and I think that what the Chrome dev tools returned me about the js heap could be worrying, but I honestly lack on this subject.

I don't understand the straight drop at ~20000ms, the straight line soon after and the other drop at ~60000ms: what are they due to? Are those behaviours normal or do they means that something should be fixed?

enter image description here

like image 821
Nad G Avatar asked Sep 19 '17 15:09

Nad G


People also ask

How do I stop Javascript heap out of memory?

Open the Start menu, search for Advanced System Settings, and select the Best match. In the Variable name field enter NODE_OPTIONS. In the Variable value field enter --max-old-space-size=4096. This value will allocate 4GB of virtual memory to Node.

What is a good JS heap size?

4 GB of heap-memory should usually be enough for most use-cases. You can test this yourself by creating an index. js file with the following code and running it with the Node.

What does JS heap mean?

A fixed amount of memory is allocated for static data. This process is known as static memory allocation. Heap: It is used to store objects and functions in JavaScript. The engine doesn't allocate a fixed amount of memory. Instead, it allocates more space as required.


1 Answers

The incline means that the page was allocating memory in the JS heap. This is normal.

The drops mean that the browser freed up memory in the JS heap that was no longer needed. This is called garbage collection. That's normal, too. Nothing alarming about that.

In general, if you see that the total amount of memory is progressively increasing after each garbage collection event, then that's a warning sign that you have a memory leak. The memory leak pattern usually looks like this:

memory leak pattern

Source

As you can see from the graph, if you leave the page running for long enough, eventually it will use up all of the computer's memory, causing the computer to run slowly, or crash.

See Fix Memory Problems for more techniques for analyzing memory usage.

like image 166
Kayce Basques Avatar answered Sep 20 '22 23:09

Kayce Basques