GP-6213: You can now set Ghidra MAXMEM via an assortment of environment

variables
This commit is contained in:
Ryan Kurtz
2025-12-12 13:00:35 -05:00
parent f6274f373f
commit 082c04c545
13 changed files with 135 additions and 56 deletions
@@ -4,9 +4,17 @@
# Ghidra Headless Analyzer launch (see analyzeHeadlessREADME.html)
#----------------------------------------------------------------------
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
MAXMEM=2G
# Optionally override the default Java heap memory, which is typically 1/4 of system RAM.
# Supported values are of the regular expression form "\d+[gGmMkK]", allowing the value to be
# specified in gigabytes, megabytes, or kilobytes (for example: 8G, 4096m, etc).
# We override the default for headless in case users spin up many headless instances in parallel.
MAXMEM_DEFAULT=2G
# Allow the above MAXMEM_DEFAULT to be overridden by externally set environment variables
# - GHIDRA_MAXMEM: Desired maximum heap memory for all Ghidra instances
# - GHIDRA_HEADLESS_MAXMEM: Desired maximum heap memory only for headless Ghidra instances
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_HEADLESS_MAXMEM=${GHIDRA_HEADLESS_MAXMEM:=${GHIDRA_MAXMEM}}
# Launch mode can be changed to one of the following: fg, debug, debug-suspend
LAUNCH_MODE=fg
@@ -29,4 +37,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch HeadlessAnalyzer.
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${GHIDRA_HEADLESS_MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"
+11 -4
View File
@@ -2,9 +2,16 @@
#
# Command-line script for interacting with a BSim database
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
#MAXMEM=2G
# Optionally override the default Java heap memory, which is typically 1/4 of system RAM.
# Supported values are of the regular expression form "\d+[gGmMkK]", allowing the value to be
# specified in gigabytes, megabytes, or kilobytes (for example: 8G, 4096m, etc).
MAXMEM_DEFAULT=
# Allow the above MAXMEM_DEFAULT to be overridden by externally set environment variables
# - GHIDRA_MAXMEM: Desired maximum heap memory for all Ghidra instances
# - GHIDRA_BSIM_MAXMEM: Desired maximum heap memory only for Ghidra BSim instances
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_BSIM_MAXMEM=${GHIDRA_BSIM_MAXMEM:=${GHIDRA_MAXMEM}}
# launch mode (fg, bg, debug, debug-suspend)
LAUNCH_MODE=fg
@@ -18,4 +25,4 @@ VMARG_LIST="-Djava.awt.headless=true "
SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
SCRIPT_DIR="${SCRIPT_FILE%/*}"
${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" "${MAXMEM}" "${VMARG_LIST}" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"
${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" "${GHIDRA_BSIM_MAXMEM}" "${VMARG_LIST}" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"
@@ -4,9 +4,16 @@
# Ghidra debug launch
#----------------------------------------
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
#MAXMEM=2G
# Optionally override the default Java heap memory, which is typically 1/4 of system RAM.
# Supported values are of the regular expression form "\d+[gGmMkK]", allowing the value to be
# specified in gigabytes, megabytes, or kilobytes (for example: 8G, 4096m, etc).
MAXMEM_DEFAULT=
# Allow the above MAXMEM_DEFAULT to be overridden by externally set environment variables
# - GHIDRA_MAXMEM: Desired maximum heap memory for all Ghidra instances
# - GHIDRA_GUI_MAXMEM: Desired maximum heap memory only for Ghidra GUI instances
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_GUI_MAXMEM=${GHIDRA_GUI_MAXMEM:=${GHIDRA_MAXMEM}}
# Debug launch mode can be changed to one of the following: debug, debug-suspend
LAUNCH_MODE=debug
@@ -24,4 +31,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra in debug mode
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "" ghidra.GhidraRun "$@"
+11 -4
View File
@@ -4,9 +4,16 @@
# Ghidra JShell launch
#----------------------------------------
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
#MAXMEM=2G
# Optionally override the default Java heap memory, which is typically 1/4 of system RAM.
# Supported values are of the regular expression form "\d+[gGmMkK]", allowing the value to be
# specified in gigabytes, megabytes, or kilobytes (for example: 8G, 4096m, etc).
MAXMEM_DEFAULT=
# Allow the above MAXMEM_DEFAULT to be overridden by externally set environment variables
# - GHIDRA_MAXMEM: Desired maximum heap memory for all Ghidra instances
# - GHIDRA_JSHELL_MAXMEM: Desired maximum heap memory only for Ghidra JShell instances
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_JSHELL_MAXMEM=${GHIDRA_JSHELL_MAXMEM:=${GHIDRA_MAXMEM}}
# Resolve symbolic link if present and get the directory this script lives in.
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
@@ -16,4 +23,4 @@ SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo
SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra
"${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${MAXMEM}" "" ghidra.JShellRun "$@"
"${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${GHIDRA_JSHELL_MAXMEM}" "" ghidra.JShellRun "$@"
+11 -4
View File
@@ -4,9 +4,16 @@
# Ghidra Jython launch
#----------------------------------------
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
#MAXMEM=2G
# Optionally override the default Java heap memory, which is typically 1/4 of system RAM.
# Supported values are of the regular expression form "\d+[gGmMkK]", allowing the value to be
# specified in gigabytes, megabytes, or kilobytes (for example: 8G, 4096m, etc).
MAXMEM_DEFAULT=
# Allow the above MAXMEM_DEFAULT to be overridden by externally set environment variables
# - GHIDRA_MAXMEM: Desired maximum heap memory for all Ghidra instances
# - GHIDRA_JYTHON_MAXMEM: Desired maximum heap memory only for Ghidra Jython instances
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_JYTHON_MAXMEM=${GHIDRA_JYTHON_MAXMEM:=${GHIDRA_MAXMEM}}
# Launch mode can be changed to one of the following: fg, debug, debug-suspend
LAUNCH_MODE=fg
@@ -33,4 +40,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra Jython
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Jython" "${MAXMEM}" "${VMARG_LIST}" ghidra.jython.JythonRun "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Jython" "${GHIDRA_JYTHON_MAXMEM}" "${VMARG_LIST}" ghidra.jython.JythonRun "$@"