How to Count Number of Instances of a Class

后端 未结 9 1342
小鲜肉
小鲜肉 2020-12-15 10:46

Can anyone tell me how to count the number of instances of a class?

Here\'s my code

public class Bicycle {

    //instance variables
    public int          


        
9条回答
  •  借酒劲吻你
    2020-12-15 11:33

    Pleae try the tool of java

    jmap -histo 
    

    Out put

         num     #instances         #bytes  class name
    ----------------------------------------------
       1:       1105141       97252408  java.lang.reflect.Method
       2:       3603562       86485488  java.lang.Double
       3:       1191098       28586352  java.lang.String
       4:        191694       27035744  [C
    

提交回复
热议问题