I've been inspecting objects and I noticed that the size of a java.lang.String is always 24 bytes, regardless of the text it contains.
For example:
String str1 = "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
String str2 = "test";
When computing the Strings' sizes using this method:
String test = "hello";
for(int i=0; i<10000; i++){
test += test + i;
}
log.debug( Agent.inst.getObjectSize( test ) );
It tells me that both strings are 24 bytes.
I know that all objects store only the address of the value and that value is static, but I don't understand what I'm observing. What's going on?