【发布时间】:2018-09-13 04:23:07
【问题描述】:
当我们定义一个Java类时,我们可以在堆中获取Obeject的内存使用情况,但是由于程序的未知行为,我们无法获取运行时内存使用情况。比如下面的类:
public class Sample{
private int age;
private String name;
private static List scores = new ArrayList<Integer>();
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
scores.add(sc.nextInt());
}
}
}
那我们如何获取Sample类的运行时内存使用情况?
【问题讨论】:
-
这里列出了许多技术:stackoverflow.com/questions/21535189/…