如何查找堆中的对象数 [英] How to find the number of objects in the heap
本文介绍了如何查找堆中的对象数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Java程序中找到堆上活动对象的数量?
How can I find the number of live objects on the heap in Java program?
推荐答案
有一个hack你可以尝试:
There is a hack you can try:
- 创建自己的java.lang.Object(复制原始来源)
- count构造函数中创建的对象(不为数组调用)
- 将类文件的路径添加到引导类路径
查看此(旧)文章了解样本。
see this (old) article for a sample.
可能有更好的方法来使用 JPDA 或 JMX ,但我还没找到......
Probably there are better ways to do it using JPDA or JMX, but I've not found how...
这篇关于如何查找堆中的对象数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文