任务管理器显示内存泄漏,但堆快照不显示 [英] Task manager shows memory leak, but Heap snapshot doesn't

查看:117
本文介绍了任务管理器显示内存泄漏,但堆快照不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每5秒钟运行沉重的JavaScript,任务管理器显示内存使用率不断增加.但是堆快照没有.如果我停止脚本,则大约半分钟 两分钟后会清除内存.

I run heavy JavaScript every 5 seconds and task manager shows constant increase of memory usage. However Heap snapshot doesn't. If I stop the script, memory is cleared after about half a minute two minutes.

更新:

如果我长时间离开脚本,则内存会增加,直到浏览器崩溃为止. 我还尝试对chrome开发工具进行时间轴测试,并且它们也没有显示出与堆快照相同的内存使用率增加.所以我想这是某种泄漏,但我不明白泄漏的是什么.

If I leave the script for a long time, the memory increases until the browser crashes. I also tried to run timeline test of chrome dev tools, and they also don't show the increase of memory usage, same as Heap snapshot. So I guess it's some kind of a leak, but I can't understand what is leaking.

我无法确认的另一件事,因为我无法安装以前的Chrome版本,所以我不记得在以前的版本(<24个Chrome版本)中会发生这种情况. IE10在不增加内存的情况下运行此测试.难道这是新版Chrome的问题?

Another thing which I can't confirm, as I can't install previous Chrome versions is that I don't remember this happening on previous (<24 Chrome versions). And IE10 runs this test without increasing memory. Could this be issue of new Chrome?

推荐答案

假设您使用的是Chrome开发者工具,则可能看不到堆快照中的内存增加,因为堆快照探查器在运行垃圾收集器之前快照.

Assuming you are referring to the Chrome Developer Tools, you might not be seeing the memory increase in the Heap snapshot, because the Heap snapshot profiler runs the Garbage Collector before the snapshot.

看到内存使用增加,尤其是在活动处理期间,是很正常的.垃圾收集器不会不必要地运行.如果您的计算机有可用的内存,它将让保留的内存增加.如果您开始增加可用内存的限制,则收集器应运行.您应该允许它发生,看看是否可以.

Seeing increased memory usage, especially during active processing, is quite normal. The garbage collector doesn't run unnecessarily. If your machine has memory to spare, it'll let the reserved memory grow. If you start pushing the limit of free memory, the collector should run. You should allow this to happen to see if it does.

由于您报告在空闲一段时间后内存已下降到原始级别,这表明没有内存泄漏,并且垃圾收集器能够正确收集所有分配的堆对象.

Since you report that the memory goes down to it's original level after an idle period, that indicates that there is no memory leak, and the garbage collector is able to collect all allocated heap objects correctly.

但是,IANAGE(我不是Google工程师).我建议阅读堆分析器文档和相关的内存101"页面作为背景.

However, IANAGE (I am not a Google engineer). I recommend reading the Heap Profiler documentation and the associated Memory 101 page for background.

这篇关于任务管理器显示内存泄漏,但堆快照不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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