Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6067 Improve memory settings and docs related to Ghidra Server service wrapper

ghidra166be2b6a2bdc
diff --git a/Ghidra/RuntimeScripts/Common/server/server.conf b/Ghidra/RuntimeScripts/Common/server/server.conf
index 82d675b3b9..eb4a4dc1bb 100644
--- a/Ghidra/RuntimeScripts/Common/server/server.conf
+++ b/Ghidra/RuntimeScripts/Common/server/server.conf
@@ -1,6 +1,15 @@
-#********************************************************************
+#**************************************************************************
# Service Wrapper Properties
-#********************************************************************
+#
+# NOTE: It is important to know that the Ghidra Server consists of both
+# a controlling wrapper process and its wrapped child process. The
+# properties within this file may affect each differently - specifically
+# JVM options and how they are specified. The service wrapper relies on
+# wrapper.ntservice.additional.N properties within this file, while the
+# wrapped Ghidra Server child process relies on wrapper.java.additional.N
+# properties. Any changes to ntservice properties require reinstallation
+# of the service for them to have any affect.
+#**************************************************************************
# Initial Working Directory (i.e., absolute installation directory path)
wrapper.working.dir=${ghidra_home}
@@ -107,11 +116,13 @@ wrapper.java.monitor.deadlock = true
# Main server application class
wrapper.java.app.mainclass=ghidra.server.remote.GhidraServer
-# Initial Java Heap Size (in MB)
+# Initial Java Heap Size (in MB) - this has the same affect as JVM option -Xms
+# NOTE: See ntservice options at bottom of this file for installed service wrapper control
wrapper.java.initmemory=396
-# Maximum Java Heap Size (in MB)
+# Maximum Java Heap Size (in MB) - this has the same affect as JVM option -Xmx
# See svrREADME.txt file for advice (Server Memory Considerations)
+# NOTE: See ntservice options at bottom of this file for installed service wrapper control
wrapper.java.maxmemory=768
# Specify the directory used to store repositories. This directory must be dedicated to this
@@ -259,3 +270,16 @@ wrapper.ntservice.interactive=false
# Restart failed service after 1 minute delay
wrapper.ntservice.failure_actions.actions=RESTART
wrapper.ntservice.failure_actions.actions_delay=60000
+
+# Specify JVM arguments to be used by installed service wrapper process.
+
+# Maximum Java Heap Size (in MB) for installed service wrapper.
+# NOTE: See also -Xmx option specification with ghidraSvr script which relates to other
+# uses of the YAJSW wrapper (e.g., console mode).
+wrapper.ntservice.additional.1=-Xmx1G
+
+# Uncomment to enable detailed memory tracking capability for the installed service wrapper process.
+# This will allow command such as the following to dump memory use information:
+# jcmd <PID> VM.native_memory summary
+# jcmd <PID> VM.native_memory detail
+#wrapper.ntservice.additional.2=-XX:NativeMemoryTracking=detail
diff --git a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr
index bb171c202d..ee26ee799c 100755
--- a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr
+++ b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr
@@ -171,7 +171,10 @@ else
JAVA_CMD="${LS_JAVA_HOME}/bin/java"
fi
+# Specify JVM arguments for direct invocations of YAJSW wrapper, including specification
+# of maximum heap size (-Xmx) option.
VMARGS=()
+VMARGS+=("-Xmx1G")
VMARGS+=("-Djna_tmpdir=${WRAPPER_TMPDIR}")
VMARGS+=("-Djava.io.tmpdir=${WRAPPER_TMPDIR}")