JavaScript memory limit

Is there a maximum amount of data that a JavaScript application can store?

I assume this is handled by the browser, and each has its own limitations?

If there is no limit, will a page file be created? If so, is it really unsafe?

+50
javascript browser memory
May 29, '10 at 22:21
source share
5 answers

AFAIK, there is no upper limit, your script can basically use memory until the system runs out of memory (including swap). No upper limit means you have to eat it all, users may not like it.

+34
May 29 '10 at
source share

On Chrome and Chromium OS, the memory limit is determined by the browser, and you can check the limit with the following command in the developer tools command line by pressing F12:

> window.performance.memory.jsHeapSizeLimit 1090519040 

On my Windows 10 OS, it's about 1 GB.

In Chrom (e / ium), you can get around the heap size limit by allocating your own arrays:

 var target = [] while (true) { target.push(new Uint8Array(1024 * 1024)); // 1Meg native arrays } 

This causes the tab to crash about 2 GB, which happens very quickly. After that, Chrom (e / ium) fails, and it is impossible to repeat the test without restarting the browser.

I also recommend reading the TrackJS blog on JavaScript memory monitoring before delving into the weeds, trying to diagnose or measure anything related to the browser.

You can also find javascript memory limit in comp.lang.javascript.

See also these messages:

  1. The maximum array size in Javascript , which assumes you can store up to 2 32 -1 = 4 294 967 295 = 4.29 billion elements.

  2. The maximum number of arguments that a JavaScript function can accept.

The JS9 Astronomical Image Display Library website has more information: working with memory limitations .

(I tried to find a good answer, and the answer “no upper limit” given here was simply stupid for me. I cannot run into a production problem for a multi-million dollar project and say to the management: “Well, I assumed that there is no upper limit, and everything will be okay. "Try checking the concept, for example, loading a lot of list controls into the selected JavaScript UI, etc. You may find that your environment has some performance degradation .)

Here are some of the components that I found very scalable in terms of processor performance and memory performance:

  1. Microsoft Monaco Editor
    • This is used by several commercial projects:
      1. Postman, from v7.1.1-canary08
      2. Code VS

Here are some examples of platforms with known performance degradation:

  1. Corner: Poor approach to detecting changes.
    • For each asynchronous event, compare each binding (Model-Dom binding) to its old value to decide whether to re-render.
      1. NG1:> 2500 viewers, performance stops
      2. NG2: the same problem remains, but you have a long tedious workaround: switch to immutable and distribute ChangeDetectionStrategy.on Swipe throughout the application to disable the default problematic strategy
  2. to react
    • Again, immutable collections of JS objects are so far only scalable.
      1. A create-responsive application using Immutable.JS and Immutable.JS internally can only create about 500 thousand immutable collections before it dies.

Here are a few more things to consider:

  1. Use array.slice to manipulate arrays to minimize additional array allocations; array.slice will change the array in place, which will reduce garbage collection and overall heap size.
+23
Aug 28 '12 at 16:28
source share

There are no memory limits for the Javascript program. Your script can run all the RAM on your computer. However, it is not recommended to use all the memory on the user's computer. If you are dealing with a lot of data, I would suggest you check the caching.

+3
May 29 '10 at 22:51
source share

Firefox supports the " javascript.options.mem.max " option, and if you look for it, you can find a discussion about reasonable values ​​that people have found workable.

Not sure how many people might be worried about what was going on there, and installing it, but speaking for myself, I set it to 128000 (this is 128 M).

+3
Feb 12 '17 at 0:28
source share

I think the memory limit is from the browser. We can use DevTools to figure this out. Like Chrome, press F12 and enter window.performance.memory to see the memory information.

  window.performance.memory 

enter image description here

+3
Dec 06 '18 at 6:26
source share



All Articles