Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Heap Size and Chrome Increasing

I have a single web page application that is all JavaScript. I noticed the JavaScript heap size goes up on each AJAX call that returns a new view. Is there something I should be doing to clean up the older views?

like image 269
Mike Flynn Avatar asked Nov 05 '12 21:11

Mike Flynn


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.

Why Javascript heap out of memory occurs?

This generally occurs on larger projects where the default amount of memory allocated by Node (1.5gb) is insufficient to complete the command successfully.

What is JS heap size?

usedJsHeapSize is the total amount of memory being used by JS objects including V8 internal objects, totalJsHeapSize is current size of the JS heap including free space not occupied by any JS objects. This means that usedJsHeapSize can not be greater than totalJsHeapSize.


1 Answers

I would recommend you to take a look at the following resources. You can see how to inspect the browser timeline in order to detect leaking references and performance problems.

The first one is from a Chrome developer talking this year at the Google IO:

http://www.youtube.com/watch?v=3pxf3Ju2row

The second one is from Paul Irish talking at the breaking point episode 2:

http://www.youtube.com/watch?v=PPXeWjWp-8Y

I'm sure you will find a lot of clues!! Anyway ... if you share a test case of your code at jsfiddle.net, we can take a look :)

like image 128
borillo Avatar answered Oct 06 '22 01:10

borillo