when we define a Java class, we can get the Obeject's memory usage in heap,but we cannot get the runtime memory usage becasuse of the program's unknown behaviors。such as the follow class:
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());
}
}
}
then how do we get the runtime memory usage of the class Sample?