Java GC:提升顶级对象类(按大小)? [英] Java GC: top object classes promoted (by size)?

查看:142
本文介绍了Java GC:提升顶级对象类(按大小)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请让我知道在每次年轻的GC事件发生后,确定年老一代的年轻一代记忆组合的最佳方法是什么?



理想情况下,我希望知道每个年轻人 - >老年人促销大块中80%堆的类名称。



例如:我有600M的年轻人,每个任期都提升6M;我想知道哪些对象组成了这6M。



谢谢。

解决方案

有没有简单的方法来做到这一点,但是,我最近一直在分析大型java应用程序的内存性能,并可以分享一些经验。



我发现哪些对象正在升级到旧版本:



首先,您需要确定哪些对象处于旧/终身空间。这基本上是你的标准java堆分析。为此我推荐jmap。它是sun jvm的一部分。
运行:
jmap -dump:file = heap.hprof PID
获取堆转储。这会在转储过程中暂停jvm(〜在2GB堆上停留30秒)



现在将.prof文件加载到内存分析器(这是最好的工具,传递信息)
我会花费一个一天玩记忆分析仪了解它,看屏幕摄像头(需要登录,但值得)。

现在你会知道你的堆里有什么物体。 p>

下面是一个技巧:在内存分析器的概览屏幕中,有一个链接:无法访问的对象直方图。现在这些对象都是在下一次GC会议期间收集的。但有些可能在伊甸园中,有些在幸存者中,有些在过去。

现在,使用内存分析功能获取一些分析器,我更喜欢yourKit。
使用yourkit运行您的应用程序并记录对象分配。



运行它并记录对象创建。一旦你有一个创建的对象列表使用所有三个列表来获取正在发生的事情的图片。做什么是人类最擅长的,见模式。




  • 创建并可以访问哪些对象。 (内存分析器)
  • 在堆(内存分析器)中无法访问的对象

  • 运行期间创建的对象(Profiler)


另一种方法是YourKit 世代观点。您可以拍摄堆的快照,并比较快照之间仍然存在的对象。如果您通过 visualgc 使用此功能,您可以确定对象必须持续多长时间活着被提升为老一辈,并在这些间隔拍摄快照,看看哪些物体还活着。



好的,祝你好运。
/ JT


Please let me know what is the best way to determine composition of young generation memory promoted to old generation, after each young GC event?

Ideally I would like to know class names which are responsible say, for 80% of heap in each "young gen -> old gen" promotion chunk;

Example: I have 600M young gen, each tenure promotes 6M; I want to know which objects compose this 6M.

Thank you.

解决方案

There is no easy way to do this, however, I have recently been analyzing memory performance of large java apps, and can share some experience.

Here is how I found what objects are being promoted to old gen:

First you need to identify what objects are in "old/tenured" space. This is basically you standard java heap analysis. For this I recommend jmap. It is part of the sun jvm. run: jmap -dump:file=heap.hprof PID to get a heap dump. This will pause the jvm during the dump (~for 30 secs on a 2GB heap)

Now load the .prof file in Memory analyser (the best tool for this, hands down) I would spend a day playing with Memory analyzer to understand it, watch the screencam (needs a login, but worth it).

Now you will know what objects are in your heap.

Here is the trick: In the overview screen of Memory analyser, there is a link to: "Unreachable objects histogram". Now these objects are all to be collected during the next GC. But some are probably in eden, some in survivor and some in old.

Now, get some profiler with memory profiling capability, I prefer yourKit. Run your app with yourkit and record object allocation.

Run it and record object creation. Once you have a list of objects created use all three lists to get a picture of what is going on. Do what humans do best, see patterns.

  • What objects are created and are reachable. (Memory analyser)
  • Objects unreachable in heap (Memory analyser)
  • Objects created during a run (Profiler)

Another way to approach is YourKit generations view. You can take snapshots of your heap and compare what objects are still alive between snapshots. If you use this with visualgc you can determine how long an object must be alive to be promoted to old gen, and take snapshots at these intervals to see what objects are still alive.

Well, good luck. /JT

这篇关于Java GC:提升顶级对象类(按大小)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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