@@ -85,11 +85,52 @@ The moral of the story is this: even when you have memory to spare, try to avoid
85
85
crossing the 32 GB heap boundary. It wastes memory, reduces CPU performance, and
86
86
makes the GC struggle with large heaps.
87
87
88
- With the HotSpot JVM, you can verify that your max heap size setting enables compressed
89
- oops by adding `-XX:+PrintFlagsFinal` and checking that the value of the `UseCompressedOops`
90
- flag is `true`. Do note that the exact cutoff for max heap size in bytes that allows
91
- compressed oops varies from JVM to JVM, so take caution when taking examples from
92
- elsewhere and be sure to check your system with your configuration and your JVM.
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:
99
+
100
+ [source,bash]
101
+ ----
102
+ $ JAVA_HOME=`/usr/libexec/java_home -v 1.7` java -Xmx32600m -XX:+PrintFlagsFinal 2> /dev/null | grep UseCompressedOops
103
+ bool UseCompressedOops := true
104
+ $ JAVA_HOME=`/usr/libexec/java_home -v 1.7` java -Xmx32766m -XX:+PrintFlagsFinal 2> /dev/null | grep UseCompressedOops
105
+ bool UseCompressedOops = false
106
+ ----
107
+
108
+ In contrast, a Java 1.8 installation on the same machine has a max heap size
109
+ around 32766mb (~31.99gb):
110
+
111
+ [source,bash]
112
+ ----
113
+ $ JAVA_HOME=`/usr/libexec/java_home -v 1.8` java -Xmx32766m -XX:+PrintFlagsFinal 2> /dev/null | grep UseCompressedOops
114
+ bool UseCompressedOops := true
115
+ $ JAVA_HOME=`/usr/libexec/java_home -v 1.8` java -Xmx32767m -XX:+PrintFlagsFinal 2> /dev/null | grep UseCompressedOops
116
+ bool UseCompressedOops = false
117
+ ----
118
+
119
+ The morale of the story is that the exact cutoff to leverage compressed oops
120
+ varies from JVM to JVM, so take caution when taking examples from elsewhere and
121
+ be sure to check your system with your configuration and JVM.
122
+
123
+ Beginning with Elasticsearch v2.2.0, the startup log will actually tell you if your
124
+ JVM is using compressed OOPs or not. You'll see a log message like:
125
+
126
+ [source, bash]
127
+ ----
128
+ [2015-12-16 13:53:33,417][INFO ][env] [Illyana Rasputin] heap size [989.8mb], compressed ordinary object pointers [true]
129
+ ----
130
+
131
+ Which indicates that compressed object pointers are being used. If they are not,
132
+ the message will say `[false]`.
133
+
93
134
94
135
[role="pagebreak-before"]
95
136
.I Have a Machine with 1 TB RAM!
0 commit comments