Given this heap heap
size no. of obj class 515313696 2380602 char[] 75476832 614571 * ConstMethodKlass 57412368 2392182 java.lang.String 44255544 614571 * MethodKlass 33836872 70371 * ConstantPoolKlass 28034704 70371 * InstanceKlassKlass 26834392 349363 java.lang.Object[] 25853848 256925 java.util.HashMap$Entry[] 24224240 496587 * SymbolKlass 19627024 117963 byte[] 18963232 61583 * ConstantPoolCacheKlass 18373920 120113 int[] 15239352 634973 java.util.HashMap$Entry 11789056 92102 ph.com.my.class.Person
And only 1 class from my application, ph.com.my.class.Person . Class definition:
public class Person { private String f_name; private String l_name; }
In a heap dump, does Person size (11789056) memory that 2 string variables occupy? Or instead of f_name and l_name will be considered in the String class, in this case the size is 57412368?
UPDATED - added the following question:
So let's say each instance:
- f_name size 30
- l_name size 20
- Person Size - 75
If there are 10 instances of Person, there will be
- 10 * (30 + 20) = 500
- 10 * 75 = 750
Will 500 be counted in String or char []? And subsequently, will 750 be counted in the Person?
source share