Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6067 Limit Ghidra Server service wrapper to 512MB heap size

ghidra1996f6d5e8a47
diff --git a/Ghidra/RuntimeScripts/Common/server/server.conf b/Ghidra/RuntimeScripts/Common/server/server.conf
index eb4a4dc1bb..c1fd8d77fa 100644
--- a/Ghidra/RuntimeScripts/Common/server/server.conf
+++ b/Ghidra/RuntimeScripts/Common/server/server.conf
@@ -273,10 +273,10 @@ 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.
+# Maximum Java Heap Size 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
+wrapper.ntservice.additional.1=-Xmx512M
# 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:
diff --git a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr
index ee26ee799c..934063daed 100755
--- a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr
+++ b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr
@@ -174,7 +174,7 @@ fi
# Specify JVM arguments for direct invocations of YAJSW wrapper, including specification
# of maximum heap size (-Xmx) option.
VMARGS=()
-VMARGS+=("-Xmx1G")
+VMARGS+=("-Xmx512M")
VMARGS+=("-Djna_tmpdir=${WRAPPER_TMPDIR}")
VMARGS+=("-Djava.io.tmpdir=${WRAPPER_TMPDIR}")
diff --git a/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat b/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat
index 702cbb7f6a..246f171b7e 100644
--- a/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat
+++ b/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat
@@ -185,7 +185,10 @@ set "java=%LS_JAVA_HOME%\bin\java.exe"
:: execute command OPTION
:lab3
-set VMARGS=-Djava.io.tmpdir="%WRAPPER_TMPDIR%"
+:: Specify JVM arguments for direct invocations of YAJSW wrapper, including specification
+:: of maximum heap size (-Xmx) option.
+set VMARGS=-Xmx512M
+set VMARGS=%VMARGS% -Djava.io.tmpdir="%WRAPPER_TMPDIR%"
set VMARGS=%VMARGS% -Djna_tmpdir="%WRAPPER_TMPDIR%"
:: set DEBUG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:18888