Chrome标签页内存不断增长,堆大小保持不变 [英] Chrome tab memory keeps growing, heap size stays the same

查看:766
本文介绍了Chrome标签页内存不断增长,堆大小保持不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与一个团队合作处理一个页面应用程序,该应用程序有很多计时器,每秒大约有10个REST API调用.我们使用了Chrome内存分析工具来定位我们所有的内存泄漏-此时堆大小保持不变(即在垃圾回收之间).

但是,我们注意到应用程序运行的时间越长,Chrome选项卡本身使用的内存就越大.几个小时后,我们已经看到选项卡内存增长到大约350MB,而堆大小保持在6MB.如果整夜运行,该标签页将占用500MB以上的空间,到早晨将无法使用.

我们需要该应用程序长时间运行(我们希望每周仅重新启动一次),所以这是一个问题.

这是一个小时内堆时间轴的屏幕截图.最后,该选项卡的专用内存大小为350MB,而堆的大小保持在5.4MB左右.

我们已经在Windows 7的Chrome 40和Chrome 38中看到了这一点.我们已禁用缓存,并以隐身模式运行该应用程序.

有人知道为什么选项卡的内存大小会增长到无法使用Chrome的程度,而JS堆的使用仍然很小吗?

编辑:我们将应用程序运行了两天,而选项卡的内存大小最大为800MB,堆大小仍然大致相同.

编辑(6/9/15):我不确定这是否在任何地方都有记录,但是Chrome似乎会根据系统上的可用内存量.因此,如果您有很多可用内存,那么制表符将使用很多内存,而如果您没有太多可用内存,那么它将不会使用太多内存.这似乎与堆大小不成比例,可能只是Chrome保留以使其自身更快而已的东西.这只是一个理论,基于监视Chrome的内存使用情况:)

解决方案

这可能已经太老了,不再适用了,但对于其他经历过此问题的其他人来说:这可能是由于开发工具已打开.我有一个应用程序,该应用程序会随着时间的推移在堆大小不变的情况下累积内存,但是当我关闭开发工具时,内存下降了,并且没有像打开开发工具时那样恢复.在分析长期内存占用量时,请首先使用chrome任务管理器.

在您的情况下,我可以猜测是因为devtools必须存储所有这些REST API调用(以在网络"标签中显示),而且我不确定chrome是否将它们临时保存到磁盘以节省内存. >

I'm working with a team on a single page application with quite a few timers, and about 10 REST API calls per second. We've used the Chrome memory profiling tools to locate all of our memory leaks--at this point the heap size stays about the same (i.e. in between garbage collections).

However, we're noticing that the longer the application runs, the more memory the Chrome tab itself uses. After a few hours, we've seen the tab memory grow to about 350MB, while the heap size remains at 6MB. If run overnight, the tab consumes over 500MB and becomes unusable by morning.

We need the application to run for long periods of time (we're hoping to restart it only once a week), so this is a problem.

Here's a screenshot of the heap timeline over the course of an hour. At the end, the tab's private memory size is 350MB, while the heap's size remained at around 5.4MB.

We've seen this in Chrome 40 and Chrome 38, on Windows 7. We have caching disabled, and are running the application in incognito mode.

Any idea why the tab memory size would grow to the point where Chrome is unusable, while the JS heap usage remains so small?

EDIT: We ran the app for a couple days and the tab memory size is up to 800MB, heap size still about the same.

EDIT (6/9/15): I'm not sure if this is documented anywhere, but it seems like Chrome changes the amount of memory it will allocate to a tab, based on the amount of free memory on the system. So, if you have a lot of free memory, tabs will use a lot of memory, and if you don't have much, it won't use as much. This doesn't seem to be proportional to heap size, it's probably just stuff that Chrome keeps around to make itself faster. This is only a theory, based on monitoring Chrome memory usage :)

解决方案

This is probably too old and not relevant anymore, but for everyone else who experienced this: it's probably because of the opened dev tools. I had an application that would accumulate memory over time with the heap size staying the same, but when I closed the dev tools the memory went way down and didn't get back up like it did when dev tools was open. When profiling long term memory footprint, use chrome task manager first.

I can guess that in your case it happens because devtools has to store all those REST API calls (to show them in Network tab) and I'm not sure if chrome saves them to disk temporarily to save memory.

这篇关于Chrome标签页内存不断增长,堆大小保持不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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