I have a long-running (multiple days) application with objects that I expect to stay around for varying lengths of time before they can be garbage collected. Let's say there's four categories:
我有一个长期运行(多天)的应用程序,我希望它们可以在垃圾收集之前保持不同的时间长度。让我们说有四类:
- Very short-lived (<1s)
- Alive for the duration of user attention (1s < 18h)
- Daily data (~24h)
- 'Eternal' (very few, life of the application)
非常短暂(<1s)
活跃用户注意力(1s <18h)
每日数据(~24小时)
'永恒'(很少,申请的生命)
To help with tuning, I'd like to find a way of checking what actual data is getting in to the tenured generation, using the Java 6 Hotspot VM. Using jmap to generate HPROF files doesn't seem to include generational information. Is there another way of getting this information?
为了帮助调优,我想找到一种方法,使用Java 6 Hotspot VM检查实际数据进入终身代的数据。使用jmap生成HPROF文件似乎不包含世代信息。有没有其他方式来获取此信息?
1 个解决方案
#1
0
No, there is no simple way to get generation information for individual object. In fact if you ask for "live" objects, this will trigger a Full GC and place all objects into the old generation (so now you know where all the objects are, but not where they were)
不,没有简单的方法来获取单个对象的生成信息。事实上,如果你要求“实时”对象,这将触发一个完整的GC并将所有对象放入旧一代(所以现在你知道所有对象在哪里,但不知道它们在哪里)
Objects which survive a full GC are likely to be in old generation so if your system does a full GC every 5 minutes, anything which lasts longer than that is much the same.
在完整的GC中存活的对象很可能是老一代的,所以如果你的系统每5分钟完成一次完整的GC,那么任何持续时间都比这更长的东西都是一样的。
The best thing you can do is to minimise discarded objects (use a memory profiler to help) This will improve GC performance and descrease how often they occur. In extreme examples you can use off heap memory which is difficult to work with but uses next to no heap. esp useful if you have many GB of data.
您可以做的最好的事情是最小化丢弃的对象(使用内存分析器来帮助)这将提高GC性能并减少它们发生的频率。在极端的例子中,您可以使用难以使用的非堆内存,但在无堆旁边使用。如果你有很多GB的数据,esp很有用。
#1
0
No, there is no simple way to get generation information for individual object. In fact if you ask for "live" objects, this will trigger a Full GC and place all objects into the old generation (so now you know where all the objects are, but not where they were)
不,没有简单的方法来获取单个对象的生成信息。事实上,如果你要求“实时”对象,这将触发一个完整的GC并将所有对象放入旧一代(所以现在你知道所有对象在哪里,但不知道它们在哪里)
Objects which survive a full GC are likely to be in old generation so if your system does a full GC every 5 minutes, anything which lasts longer than that is much the same.
在完整的GC中存活的对象很可能是老一代的,所以如果你的系统每5分钟完成一次完整的GC,那么任何持续时间都比这更长的东西都是一样的。
The best thing you can do is to minimise discarded objects (use a memory profiler to help) This will improve GC performance and descrease how often they occur. In extreme examples you can use off heap memory which is difficult to work with but uses next to no heap. esp useful if you have many GB of data.
您可以做的最好的事情是最小化丢弃的对象(使用内存分析器来帮助)这将提高GC性能并减少它们发生的频率。在极端的例子中,您可以使用难以使用的非堆内存,但在无堆旁边使用。如果你有很多GB的数据,esp很有用。