From a3d538139283505ba64931e8e2d65b4b682039a9 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 27 Jun 2014 13:02:26 +0200 Subject: [PATCH] Disable explicit GC by default We don't rely upon GC to cleanup mappedbytebuffers, we unmap them explicitly on close in lucene. But the JDK has crazy loops with explicit GCs in exceptional cases to try to force unmapping. In general we don't want any of our code or library code calling this method: so its banned in forbidden-apis as well. --- bin/elasticsearch.bat | 3 +++ bin/elasticsearch.in.sh | 3 +++ bin/service.bat | 3 +++ core-signatures.txt | 3 +++ 4 files changed, 12 insertions(+) diff --git a/bin/elasticsearch.bat b/bin/elasticsearch.bat index b9c1bbb516c..e7f74eb17b6 100644 --- a/bin/elasticsearch.bat +++ b/bin/elasticsearch.bat @@ -62,6 +62,9 @@ REM The path to the heap dump location, note directory must exists and have enou REM space for a full heap dump. REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof +REM Disables explicit GC +set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC + set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/${project.build.finalName}.jar;%ES_HOME%/lib/*;%ES_HOME%/lib/sigar/* set ES_PARAMS=-Delasticsearch -Des-foreground=yes -Des.path.home="%ES_HOME%" diff --git a/bin/elasticsearch.in.sh b/bin/elasticsearch.in.sh index 87132059706..633b0e54977 100644 --- a/bin/elasticsearch.in.sh +++ b/bin/elasticsearch.in.sh @@ -62,3 +62,6 @@ JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" # The path to the heap dump location, note directory must exists and have enough # space for a full heap dump. #JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof" + +# Disables explicit GC +JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC" diff --git a/bin/service.bat b/bin/service.bat index 6b0e029d6b6..7bbd944119e 100644 --- a/bin/service.bat +++ b/bin/service.bat @@ -160,6 +160,9 @@ REM The path to the heap dump location, note directory must exists and have enou REM space for a full heap dump. REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof +REM Disables explicit GC +set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC + if "%DATA_DIR%" == "" set DATA_DIR=%ES_HOME%\data if "%WORK_DIR%" == "" set WORK_DIR=%ES_HOME% diff --git a/core-signatures.txt b/core-signatures.txt index 7835b1fd043..cd529e64b4d 100644 --- a/core-signatures.txt +++ b/core-signatures.txt @@ -51,5 +51,8 @@ java.lang.Object#notifyAll() java.lang.Math#abs(int) java.lang.Math#abs(long) +@defaultMessage Please do not try to stop the world +java.lang.System#gc() + @defaultMessage Use Long.compare instead we are on Java7 com.google.common.primitives.Longs#compare(long,long)