提高Chrome JS堆限制? [英] Raise Chrome JS heap limit?
问题描述
我有一个使用过多内存的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.)
A short write up of how the gc manages the heap spaces is here.
这篇关于提高Chrome JS堆限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!