You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 510_Deployment/50_heap.asciidoc
+59-11
Original file line number
Diff line number
Diff line change
@@ -52,9 +52,10 @@ heap, while leaving the other 50% free. It won't go unused; Lucene will happily
52
52
gobble up whatever is left over.
53
53
54
54
[[compressed_oops]]
55
-
==== Don't Cross 30.5 GB!
55
+
==== Don't Cross 32 GB!
56
56
There is another reason to not allocate enormous heaps to Elasticsearch. As it turns((("heap", "sizing and setting", "32gb heap boundary")))((("32gb Heap boundary")))
57
-
out, the JVM uses a trick to compress object pointers when heaps are 30.5 GB or less.
57
+
out, the HotSpot JVM uses a trick to compress object pointers when heaps are less
58
+
than around 32 GB.
58
59
59
60
In Java, all objects are allocated on the heap and referenced by a pointer.
60
61
Ordinary object pointers (OOP) point at these objects, and are traditionally
@@ -74,36 +75,83 @@ reference four billion _objects_, rather than four billion bytes. Ultimately, t
74
75
means the heap can grow to around 32 GB of physical size while still using a 32-bit
75
76
pointer.
76
77
77
-
Once you cross that magical 30.5 GB boundary, the pointers switch back to
78
+
Once you cross that magical ~32 GB boundary, the pointers switch back to
78
79
ordinary object pointers. The size of each pointer grows, more CPU-memory
79
80
bandwidth is used, and you effectively lose memory. In fact, it takes until around
80
-
40–50 GB of allocated heap before you have the same _effective_ memory of a 30.5 GB
81
-
heap using compressed oops.
81
+
40–50 GB of allocated heap before you have the same _effective_ memory of a
82
+
heap just under 32 GB using compressed oops.
82
83
83
84
The moral of the story is this: even when you have memory to spare, try to avoid
84
-
crossing the 30.5 GB heap boundary. It wastes memory, reduces CPU performance, and
85
+
crossing the 32 GB heap boundary. It wastes memory, reduces CPU performance, and
85
86
makes the GC struggle with large heaps.
86
87
88
+
==== Just how far under 32gb should I set the JVM?
89
+
90
+
Unfortunately, that depends. The exact cutoff varies by JVMs and platforms.
91
+
If you want to play it safe, setting the heap to `31gb` is likely safe.
92
+
Alternatively, you can verify the cutoff point for the HotSpot JVM by adding
93
+
`-XX:+PrintFlagsFinal` to your JVM options and checking that the value of the
94
+
UseCompressedOops flag is true. This will let you find the exact cutoff for your
95
+
platform and JVM.
96
+
97
+
For example, here we test a Java 1.7 installation on MacOSX and see the max heap
98
+
size is around 32600mb (~31.83gb) before compressed pointers are disabled:
0 commit comments