Memory usage of Java
用JDK自带的api计算size,每次都会有个多余的12,看了这些文档终于知道了
1:Memory usage of Java Strings and string-related objects
http://www.javamex.com/tutorials/memory/string_memory_usage.shtml
2:Memory usage of Java objects: general guide
http://www.javamex.com/tutorials/memory/object_memory_usage.shtml
3 How to calculate the memory usage of a Java array
http://www.javamex.com/tutorials/memory/array_memory_usage.shtml
4:Memory usage of Java Strings and string-related objects
http://www.javamex.com/tutorials/memory/string_buffer_memory_usage.shtml
啊 明白我错在哪里了 :D
请教个问题,String内存大小是如何计算的? multiply the number of characters of the String by two; add 38; if the result is not a multiple of 8, round up to the next multiple of 8; the result is generally the minimum number of bytes taken up on the heap by the String. 我只能这样算: ojbect head 为 8 bytes 3个 int 为 3*4 = 12 bytes 1个char 为 12 不考虑char大小的话,为 8+12+12=32 bytes(不是38个字节), 还有6个字节那里去了??