IMO This without the talk is not a very usable read. Maybe it's because I've already knew 95% of the concepts it was showing but I felt that the talk must have been pretty interesting as most of the presentation is just bullets points of complex topics.
Does anyone have the audio of it? Also with memory is becoming less of a problem so people tend to completely ignore it, it's nice to see something like this.
I tend to find the overhead of the JVM appears to contribute the most. If I have -Xmx 128MB for example, around 200MB will often be shown in Windows task manager, or whatever.
Maybe this is addressed in the talk, any my "overhead" is actually my own mis-used data space which I am not aware of.
The Xmx flag controls the maximum heap size. The JVM has other things that are outside of the heap (the JVM process itself, the code cache, native buffers, resource handles, etc.).
An int is 4 bytes, an Integer additionally has a 2 word object header (8 bytes) and a 4 byte reference pointing to it. This adds up to 12 bytes for the object, which is rounded up to 16 bytes, because Hotspot aligns objects to 8 byte boundaries. Including the reference, the Integer needs 20 bytes, or 5 times as much as an int.
Q: How many bytes in an 8-character String?
* object header: 8 bytes
* reference to char[] storing the value: 4 bytes
* int field to cache hashcode: 4 bytes
-> 16 bytes for "wrapper"
* char[] storing the value:
8 characters in UTF16: 16 bytes
object header: 8 bytes
length field: 4 bytes length
-> 28 bytes, rounded up to 32 bytes
total: 48 bytes
Q: Which of the following is true about HashSet relative to HashMap
d. does less, bigger: HashSet is a wrapper around HashMap
Q: Put the following 2-element collections in size order: ArrayList, HashSet, LinkedList, HashMap
Excluding the size of the actual elements:
* ArrayList, created with initial capacity of 2 (vs. default of 10):
* object header: 8 bytes
* size int: 4 bytes
* reference to Object[] holding element data: 4 bytes
-> 16 bytes for wrapper
* element data with 2 pointers: 2*4 bytes + 12 bytes, rounded
up to 24 bytes
-> 40 bytes total
* LinkedList:
* object header: 8 bytes
* size int: 4 bytes
* references to first + last node: 8 bytes
-> 20 bytes, rounded up to 24 bytes
* nodes (2x):
* object header: 8 bytes
* references to previous and next item: 8 bytes
* reference to element data: 4 bytes
-> 20 bytes, rounded up to 24
-> 72 bytes total
* HashMap, created with initial capacity of 2 (vs. 16) and default
load factor of 0.75
* object header: 8 bytes
* modification count int: 4 bytes
* size int: 4 bytes
* load factor float: 4 bytes
* entry set: ?
* resizing threshold int: 4 bytes
* pointer to hash table: 4 bytes
-> 28 bytes for wrapper, rounded up to 32 bytes
* hash table (Node[]):
* object header: 8 bytes
* length field: 4 bytes
* pointers: 4 * 4 bytes
-> 28 bytes, rounded up to 32 bytes
* Node objects (2x):
* object header: 8 bytes
* hashcode int: 4 bytes
* pointer to next node in chain: 4 bytes
* pointer to element data: 4 bytes
-> 20 bytes, rounded up to 24 bytes
-> total of 120 bytes
* HashSet, created with initial capacity of 2 (vs. 16) and default
load factor of 0.75
* object header: 8 bytes
* pointer to HashMap: 4 bytes
-> 12 bytes for wrapper, rounded up to 16
* HashMap: 120 bytes
-> 132 bytes total
Does anyone have the audio of it? Also with memory is becoming less of a problem so people tend to completely ignore it, it's nice to see something like this.