How much memory takes TreeMap<Long, Long> collection filled with 1000 (all unique) key-value pairs?
Yes I can just watch memory dump, but need to know granularly why exactly:
Long= n bytesEntry<Long, Long >= 2n bytes, so 1000 entries = 2000n bytes- reference in tree node: k bytes, 1 node have 2 links to children, so 2k bytes,
 - etc.
 
Total: X ?
                        
JOL (Java Object Layout)
To answer such questions you can use the tool, JOL.
In your case it will get such results:
Granularly
TreeMap itself:
TreeMap.Entry
And Long:
Also you may need do read additional questions about alignment and object header.