sizeof java object

前端 未结 6 1951
一生所求
一生所求 2020-11-30 13:25

How can we find out the size of a java object??

Example:

class Person{
    String name;  
    int age;  

    public Person(String n, int a){  
          


        
6条回答
  •  天命终不由人
    2020-11-30 13:32

    EhCache provides a SizeOf class that will try to use the Instrumentation agent and will fall back to a different approach if the agent is not loaded or cannot be loaded (details here).

    Also see the agent from Heinz Kabutz.

提交回复
热议问题