Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS Heap recommended memory size

Is there any limit to the heap size in the chrome memory profile ?

heap profile

like image 330
Jason Avatar asked Apr 05 '16 13:04

Jason


People also ask

What is the ideal heap size?

It is recommended to increase the Java heap space only up to one-half of the total RAM available on the server. Increasing the Java heap space beyond that value can cause performance problems. For example, if your server has 16 GB of RAM available, then the maximum heap space you should use is 8 GB.

What is heap size JS?

Heap: Dynamic memory allocation The heap is a different space for storing data where JavaScript stores objects and functions. Unlike the stack, the engine doesn't allocate a fixed amount of memory for these objects. Instead, more space will be allocated as needed.

What cause JavaScript heap out of memory?

js project is the “JavaScript heap out of memory” error. This error usually occurs when the default memory allocated by your system to Node. js is not enough to run a large project. The error is common whether you run your project on Windows, macOS, or a Linux distribution like Ubuntu.

How increase JavaScript heap size?

JavaScript heap out of memory - how to increase the max memory for Node with max_old_space_size. If you want to increase the max memory for Node you can use --max_old_space_size option. You should set this with NODE_OPTIONS environment variable.


2 Answers

Note: This is a Chrome only answer, see below why.


You should take a look at window.performance.memory in Chrome Dev Tools, there is a jsHeapSizeLimit attribute. However, I'm not sure this will be the maximum value on any memory profiling y-axis

You can find more informations on MDN : https://developer.mozilla.org/en-US/docs/Web/API/Window/performance

performance.memory :

A non-standard extension added in Chrome.

Linked in MDN (not anymore) : https://webplatform.github.io/docs/apis/timing/properties/memory/

performance.memory :

Note: This property is read-only.

console.log(performance.memory)

// Would show, for example
//{
// jsHeapSizeLimit: 767557632,
// totalJSHeapSize: 58054528,
// usedJSHeapSize: 42930044
//}

Notes

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. Note that it is not necessarily that there has ever been totalJsHeapSize of alive JS objects.

See the WebKit Patch for how the quantized values are exposed. The tests in particular help explain how it works.


Be careful, values are expressed without units because there isn't. This is because webkit does not want to expose system informations such as available memory size. It only provide a way to compare memory usage (for instace between two different versions of a website).

like image 73
Apolo Avatar answered Sep 16 '22 16:09

Apolo


In theory the memory limit (not LocalStorage, but actual memory) is unlimited, and only bounded by the amount of RAM on the system. In practice, most web browsers will place a limit on each window (for example, 200MB). Sometimes the limit is customizable by the user. Additionally, an operating system can put a limit on the amount of memory used by an application.

like image 24
Matthew Herbst Avatar answered Sep 17 '22 16:09

Matthew Herbst