最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Raise Chrome JS heap limit? - Stack Overflow

programmeradmin5浏览0评论

I have a JavaScript application that uses way too much memory. It doesn't crash out the tab, but it can take minutes to load, most of which is spent in GC. I'm using the heap profiler to see what functions are allocating the most memory, which works great.

Is there some way to get Chrome to allow a larger JS heap per process, so that I can turn around test runs on reducing memory pressure without waiting minutes for GC? A mand-line argument I couldn't find, perhaps?

I have a JavaScript application that uses way too much memory. It doesn't crash out the tab, but it can take minutes to load, most of which is spent in GC. I'm using the heap profiler to see what functions are allocating the most memory, which works great.

Is there some way to get Chrome to allow a larger JS heap per process, so that I can turn around test runs on reducing memory pressure without waiting minutes for GC? A mand-line argument I couldn't find, perhaps?

Share Improve this question asked Apr 26, 2017 at 19:54 Ben DiltsBen Dilts 10.7k18 gold badges60 silver badges86 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 13

Yes the jsHeapSizeLimit reported in the console:

 > console.memory
  MemoryInfo {totalJSHeapSize: 42100000, usedJSHeapSize: 29400000, jsHeapSizeLimit: 1620000000}

is calculated from two limits:

  size_t MaxReserved() {
    return 2 * max_semi_space_size_ + max_old_generation_size_;
  }

chromium source

You may set these maximums (in MB) with v8 flags:

chromium --js-flags="--max_old_space_size=512 --max_semi_space_size=512"

(or you can find the similarly named initial allocation flags with --js-flags=--help if you prefer.)

A short write up of how the gc manages the heap spaces is here.

发布评论

评论列表(0)

  1. 暂无评论