提高Chrome JS堆限制? [英] Raise Chrome JS heap limit?

查看:326
本文介绍了提高Chrome JS堆限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用过多内存的JavaScript应用程序.它不会使选项卡崩溃,但是加载可能需要花费几分钟,其中大部分时间都花在GC上.我正在使用堆分析器查看哪些函数分配了最多的内存,效果很好.

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.

是否有某种方法可以使Chrome浏览器在每个进程中允许更大的JS堆,以便我可以减少内存压力来进行测试运行而不必等待几分钟的时间?也许我找不到命令行参数?

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 command-line argument I couldn't find, perhaps?

推荐答案

是在控制台中报告的 jsHeapSizeLimit :

 > 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_;
  }

铬来源

您可以使用v8标志设置这些最大值(以MB为单位):

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

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

(或者,如果愿意,也可以使用-js-flags =-help 找到类似名称的初始分配标志.)

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

关于gc如何管理堆空间的简短记录是

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

这篇关于提高Chrome JS堆限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆