Skip to content

Instantly share code, notes, and snippets.

@non

non/sizes.txt

Last active Oct 16, 2019
Embed
What would you like to do?
Size of various JVM data structures in bytes (top column is number of elements).
COLLECTION 0 1 5 10 50 100 500 1000
Array[Int] 16 24 40 56 216 416 2016 4016
immutable.BitSet 24 24 24 24 24 32 96 160
immutable.IntMap[Int] 16 40 328 688 3568 7168 35968 71968
immutable.List[Int] 16 56 216 416 2016 4016 20016 40016
immutable.Map[Int,Int] 16 40 304 720 4856 9680 53504 111760
immutable.Queue[Int] 40 80 240 440 2040 4040 20040 40040
immutable.Set[Int] 16 32 264 480 3016 5840 27696 57952
immutable.SortedMap[Int,Int] 40 88 280 520 2440 4840 30008 62008
immutable.SortedSet[Int] 40 104 296 536 2456 4856 24056 48056
immutable.Stream[Int] 16 120 120 120 120 120 120 120
immutable.Stream[Int] (memoized) 16 56 216 416 2016 4016 20016 40016
immutable.TreeMap[Int,Int] 40 88 280 520 2440 4840 30008 62008
immutable.TreeSet[Int] 40 104 296 536 2456 4856 24056 48056
immutable.Vector[Int] 56 216 280 360 1288 2376 10504 20808
j.u.ArrayDeque[Int] 104 120 184 264 1096 2152 10088 20136
j.u.ArrayList[Int] 40 96 160 240 1136 2080 10240 20976
j.u.HashMap[Int] 48 176 368 608 2976 5888 34128 70224
j.u.HashSet[Int] 64 208 400 640 3008 5920 28192 56288
j.u.LinkedHashMap[Int] 56 192 416 696 3384 6696 38136 78232
j.u.LinkedHashSet[Int] 72 224 448 728 3416 6728 32200 64296
j.u.LinkedList[Int] 32 72 232 432 2032 4032 20032 40032
j.u.PriorityQueue[Int] 96 112 176 256 1048 2056 10104 20672
j.u.TreeMap[Int,Int] 48 104 328 608 2848 5648 34016 70016
j.u.TreeSet[Int] 64 136 360 640 2880 5680 28080 56080
j.u.Vector[Int] 88 104 168 248 1168 2288 10608 21168
mutable.ArrayBuffer[Int] 104 120 184 264 1096 2152 10088 20136
mutable.BitSet 40 40 40 40 40 48 96 160
mutable.Map[Int,Int] 120 160 320 520 2568 5080 30120 62216
mutable.PriorityQueue[Int] 144 160 224 304 1136 2192 10128 20176
mutable.Set[Int] 184 200 264 344 1368 2680 16248 32440
@non

This comment has been minimized.

Copy link
Owner Author

@non non commented Sep 6, 2019

I updated it to differentiate a stream before evaluation (Stream[Int]) and after evaluation (Stream[Int] (memoized)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment