谷歌浏览器查找内存泄露
I'm testing a 4GB Lenovo Yoga Pro 2 this week and I'm finding I'm running right up against the 4 gigs of RAM in my daily work. I usually have Visual Studio open, a browser, and a few other apps. I have IE, Chrome, and Firefox pinned in my Taskbar and usually work in Chrome. I (this just happened to be) had these tabs open:
我本周正在测试4GB的Lenovo Yoga Pro 2,发现我在日常工作中正面临着4GB RAM的挑战。 我通常会打开Visual Studio,浏览器和其他一些应用程序。 我的任务栏中固定了IE,Chrome和Firefox,通常可以在Chrome中使用。 我(刚好是)打开了以下标签:
- Outlook.com (work email), Gmail (home email), Twitter.com, TroyHunt.com, StackOverflow.com, ArsTechnica.com, Amazon.com Outlook.com(工作电子邮件),Gmail(家庭电子邮件),Twitter.com,TroyHunt.com,StackOverflow.com,ArsTechnica.com,Amazon.com
Here's my task manager showing the Chrome "Canary" processes:
这是我的任务管理器,显示了Chrome的“ Canary”进程:
And here's the internal Chrome task manager (which is great!) showing what's really happening:
这是内部Chrome任务管理器(太好了!),它显示了实际发生的情况:
Certainly the memory used by my growing collection of Chrome extensions adds up. Some tabs that are "apps" like Gmail and Outlook use a 100megs or more. Regular "pages" (things that aren't heavy JS users) like Troy's blog or ArsTechnical use maybe 10megs.
当然,我越来越多的Chrome扩展程序集合所占用的内存会累加起来。 Gmail和Outlook等某些“应用程序”标签使用的是100兆位或更多。 诸如Troy的博客或ArsTechnical之类的常规“页面”(不是JS高级用户)可能使用10兆位。
If I run a small PowerShell script to collect the chrome.exe's and sum their physical memory use:
如果我运行一个小的PowerShell脚本来收集chrome.exe并汇总其物理内存使用量:
$m = ps chrome | measure PM -Sum ; ("Chrome {0:N2}MB " -f ($m.sum / 1mb))
I get about 1.6 gigs! On a 4 gig machine. Ouch.
我大约有1.6场演出! 在4 gig机器上。 哎哟。
C:\> .\memory.ps1
Chrome 1,623.08MB
Virtual Memory is even worse, at 6.3gigs! I start to trim the extension-fat by going to Tools | Extensions and disabling extensions I don't need now. If I'm debugging JSON, for example, I'll turn JSONView back on as needed.
虚拟内存更糟,为6.3gigs! 我通过转到“工具” |“开始”来调整扩展脂肪。 我现在不需要的扩展和禁用扩展。 例如,如果要调试JSON,我将根据需要重新打开JSONView。
Modifying my script to measure both Virtual and Physical Memory and running again with ALL non-essential plugins turned off.
修改我的脚本以同时测量虚拟内存和物理内存,然后在所有非必需插件都关闭的情况下再次运行。
C:\> .\memory.ps1
Chrome PM 1,151.72MB
Chrome VM 4,056.56MB
Big changes. Clearly the plugin thing can get out of hand quickly and running too many on a low-memory machine is a killer. I got a half-gig of memory back disabling my extraneous extensions.
重大变化。 显然,插件程序可以很快失控,并且在低内存计算机上运行太多插件是致命的。 我有一半的内存回去禁用了多余的扩展。
Let me try the same seven sites in IE11 with no add-ons (extensions) enabled either:
让我尝试在IE11中相同的七个站点,都未启用任何加载项(扩展):
IE PM 604.11MB
IE VM 1,801.23MB
Nice improvement, less than half the VM and just over 600 megs PM. Now I'll try Firefox "Aurora." Again, same sites, logged in and running in the same state:
很好的改进,不到VM的一半,PM刚好超过600兆。 现在,我将尝试使用Firefox“ Aurora”。 同样,登录并以相同状态运行的相同站点:
Firefox PM 426.58MB
Firefox VM 824.02MB
Nice. Some excellent memory optimization work happening at Mozilla it seems.
真好看来Mozilla正在进行一些出色的内存优化工作。
Of course, this is just 7 random sites that I happened to be visiting. Here's my poorly written PowerShell script memory.ps1
当然,这只是我碰巧访问的7个随机站点。 这是我写得不好的PowerShell脚本memory.ps1
$m = ps chrome | measure PM -Sum ; ("Chrome PM {0:N2}MB " -f ($m.sum / 1mb))
$m = ps chrome | measure VM -Sum ; ("Chrome VM {0:N2}MB " -f ($m.sum / 1mb))
$m = ps firefox | measure PM -Sum ; ("Firefox PM {0:N2}MB " -f ($m.sum / 1mb))
$m = ps firefox | measure VM -Sum ; ("Firefox VM {0:N2}MB " -f ($m.sum / 1mb))
$m = ps iexplore| measure PM -Sum ; ("IE PM {0:N2}MB " -f ($m.sum / 1mb))
$m = ps iexplore| measure VM -Sum ; ("IE VM {0:N2}MB " -f ($m.sum / 1mb))
It may be that these browser builds aren't all optimize for memory usage. I don't know. They were/are the ones I have on my machine and the ones I use. Your system, your sites, your browser builds, and your video card will change these results. Measure for yourself.
这些浏览器版本可能并非全部针对内存使用进行了优化。 我不知道。 它们是我在我的机器上拥有和使用的那些。 您的系统,站点,浏览器以及视频卡都会更改这些结果。 自己测量。
For me, I need more RAM. 4gigs just isn't reasonable no matter what browser you're running.
对我来说,我需要更多的RAM。 无论您使用哪种浏览器,4gigs都是不合理的。
UPDATE: A commenter below says my results are flawed as I'm not taking into consideration how shared memory works. I am not sure (yet) I agree. Here is Chrome's about:memory feature. Who can offer thoughts?
更新:下面的评论者说我的结果存在缺陷,因为我没有考虑共享内存的工作方式。 我不确定(尚未)我同意。 这是Chrome的about:内存功能。 谁可以提供想法?
翻译自: https://www.hanselman.com/blog/finding-a-lowmemory-browser
谷歌浏览器查找内存泄露