我如何确定垃圾收集器正在收集哪些对象? [英] How can I determine what objects are being collected by the garbage collector?

查看:90
本文介绍了我如何确定垃圾收集器正在收集哪些对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有重要的垃圾收集暂停。在我尝试解决问题之前,我想查明最负责此集合的对象。我查看了Chrome上的堆快照,但(如果我错了,请纠正我)我似乎无法找到正在收集内容的任何指示符,只显示占用内存最多的内容。有没有办法根据经验来回答这个问题,还是仅限于受过教育的猜测?

一个在你想要检查的行动之前,一个之后。



现在点击第二张快照。



在底部栏上,您会看到选项框summary 。将它改为比较。

然后在旁边的选择框中选择您想要比较的快照(它应该自动选择快照1)。



作为结果,您将得到您需要的数据表。 新建和已删除对象。


I have significant garbage collection pauses. I'd like to pinpoint the objects most responsible for this collection before I try to fix the problem. I've looked at the heap snapshot on Chrome, but (correct me if I am wrong) I cannot seem to find any indicator of what is being collected, only what is taking up the most memory. Is there a way to answer this empirically, or am I limited to educated guesses?

解决方案

In chrome profiles takes two heap snapshots, one before doing action you want to check and one after.

Now click on second snapshot.

On the bottom bar you will see select box with option "summary". Change it to "comparision".

Then in select box next to it select snaphot you want to compare against (it should automaticaly select snapshot1).

As the results you will get table with data you need ie. "New" and "Deleted" objects.

这篇关于我如何确定垃圾收集器正在收集哪些对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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