実行時
java -javaagent:ObjectSizeFetcherAgent.jar PersistentTime
私は得る
24
ObjectSizeFetcherAgent
これはいつですか
public class ObjectSizeFetcher {
private static Instrumentation instrumentation;
public static void premain(String args, Instrumentation inst) {
instrumentation = inst;
}
public static long getObjectSize(Object o) {
return instrumentation.getObjectSize(o);
}
}
そして、PersistentTime
次のように見えるとき
public class PersistentTime {
List<String> list = new ArrayList<String>();
public static void main(String[] args) {
PersistentTime p = new PersistentTime();
p.list.add("a"); // The number is the same with or without this
p.list.add("b"); // The number is the same with or without this
p.list.add("c"); // The number is the same with or without this
System.out.println(ObjectSizeFetcher.getObjectSize(p));
}
}
リストに要素を追加しても効果がないのはなぜですか?