Javascript Google Chrome 浏览器是否有内存限制?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29620041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there any memory limit for Google Chrome browser?
提问by JaisoN
What is the default memory limit for a single tab in chrome ??
chrome 中单个选项卡的默认内存限制是多少?
回答by cassandrad
It's hard to answer correctly and the answer could be figured out only in benchmarks for particular task with particular build.
很难正确回答,答案只能在具有特定构建的特定任务的基准测试中找到。
There are several thing that could allow you to use from 1 to 2 GB of memory:
有几件事可以让您使用 1 到 2 GB 的内存:
- Chrome version: because different V8 engines have different memory limits.
- Chrome platform: 32-bit or 64-bit.
- Operating System itself: chrome could be built with different flags for different platforms.
- Again, Chrome version: there are some discussion on the internet about recompiling chrome with some compilation flags that could allow to use more memory, then chrome developers decide to exclude such flags because of some reasons. Who know — maybe they will include them again or will increase default heap size.
- Video memory: in some cases page's content may require some video memory and, if your video adapter has no sufficient amount, Chrome will take it from general memory, which will increase memory usage for the page.
- Chrome 版本:因为不同的 V8 引擎有不同的内存限制。
- Chrome 平台:32 位或 64 位。
- 操作系统本身:chrome 可以为不同的平台使用不同的标志构建。
- 同样,Chrome 版本:互联网上有一些关于使用一些编译标志重新编译 chrome 的讨论,这些标志可以允许使用更多内存,然后由于某些原因,chrome 开发人员决定排除这些标志。谁知道——也许他们会再次包含它们,或者会增加默认堆大小。
- 显存:在某些情况下,页面的内容可能需要一些显存,如果您的视频适配器没有足够的内存,Chrome 将从一般内存中获取它,这会增加页面的内存使用量。
Right now, with 64bit Chrome version 47, on Windows 8.1 I can take up to 1.8GB with one tab, then it crashes.
现在,使用 64 位 Chrome 版本 47,在 Windows 8.1 上,我最多可以使用一个标签占用 1.8GB,然后崩溃。
Update:
更新:
As I can see some magic has happened and limit has changed.
For Chrome version 63, on x64 Windows 10 OS, I could allocate up to 3.5 GB memory, parsing a huge JSON string and then displaying it on the page.
The number is taken from Chrome's Task manager and from Process Explorer's Private Bytesmetric.
正如我所看到的,发生了一些神奇的事情,限制也发生了变化。
对于 Chrome 63 版,在 x64 Windows 10 操作系统上,我最多可以分配 3.5 GB 内存,解析一个巨大的 JSON 字符串,然后将其显示在页面上。
该数字取自 Chrome 的任务管理器和 Process Explorer 的Private Bytes指标。
回答by Peter
There was some talking about a very similar topic. Here
有人在谈论一个非常相似的话题。这里
You should try the following:
您应该尝试以下操作:
Right click on the Chrome icon and go to properties. Chrome should be here:
右键单击 Chrome 图标并转到属性。Chrome 应该在这里:
"C:\Documents and Settings\%USER%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
Where %USER% is your username on your PC, obviously ;)
显然,%USER% 是您 PC 上的用户名;)
At the end of the line add --purge-memory-button
在行尾添加 --purge-memory-button
It should look like this:
它应该是这样的:
"C:\Documents and Settings\%USER%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" --purge-memory-button
Now, when Chrome works, press shift+Esc, and now you have a new option, "Purge Memory" which frees up memory. The tabs that do not need attention at that particular time will be purged from your RAM.
现在,当 Chrome 工作时,按 shift+Esc,现在你有了一个新选项,“清除内存”,它可以释放内存。在特定时间不需要注意的选项卡将从您的 RAM 中清除。
You can also add one of these lines:
您还可以添加以下行之一:
Never voluntarily relinquish memory
永远不要主动放弃记忆
--memory-model=high
Voluntarily reduce working set when switching tabs
切换标签时自动减少工作集
--memory-model=medium
Voluntarily reduce working set when switching tabs and also when the
在切换选项卡时以及当
--memory-model=low
Browser is not actively being used
浏览器没有被积极使用
You can have several lines after the target place "C:\Documents and Settings\%USER%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
目标位置后可以有几行 "C:\Documents and Settings\%USER%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
Let's say we wanna use the "Purge memory" line and the "Low memory model" line. It would look like this:
假设我们要使用“清除内存”行和“低内存模型”行。它看起来像这样:
"C:\Documents and Settings\%USER%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" --purge-memory-button --memory-model=low
回答by Daniel Sokolowski
I was able to increase the memory limit for my nw.js(chrome) based destkop app by passing following command line options:
我能提高我的内存限制nw.js通过将以下命令行选项(铬)基于destkop应用:
Node.js: node --max_old_space_size=12288 script.js
Google Chrome: chrome.exe --js-flags="--max_old_space_size=12288"
NW.js: add "js-flags": "--max_old_space_size=12288" to the package.json.
Adjust 12288 (12GB) to suit your needs
调整 12288 (12GB) 以满足您的需求

