OpenDJ: Find the JVM’s Default Heap and Right-Size It for Tiny Directories

TL;DR: Use jcmd to see what heap Java chose by default. For a tiny directory (~10 entries), set -Xms128m -Xmx128m in /opt/opendj/config/java.properties, restart via systemd, and verify.

Related:


Prerequisites

  • OpenDJ at /opt/opendj
  • sudo shell
  • JDK tools (jcmd):

  1. Inspect the current/default heap
# Find the OpenDJ JVM
pid=$(pgrep -f 'java .*start-ds')

# Run as the same user as OpenDJ (or use sudo)
sudo jcmd "$pid" VM.flags | tr ' ' '\n' | egrep 'InitialHeapSize|MaxHeapSize|SoftMaxHeapSize'

# Example output:
# -XX:InitialHeapSize=31457280
# -XX:MaxHeapSize=484442112
# -XX:SoftMaxHeapSize=484442112

  1. Configure a small fixed heap (tiny dataset)
cd /opt/opendj

# Replace if exists; otherwise append
if grep -q '^start-ds\.java-args=' config/java.properties; then
  sudo sed -i 's/^start-ds\.java-args=.*/start-ds.java-args=-server -Xms128m -Xmx128m -XX:+UseG1GC/' config/java.properties
else
  echo 'start-ds.java-args=-server -Xms128m -Xmx128m -XX:+UseG1GC' | sudo tee -a config/java.properties
fi

  1. Restart OpenDJ (systemd)
sudo systemctl restart opendj

  1. Verify the new heap
pid=$(pgrep -f 'java .*start-ds')
sudo jcmd "$pid" VM.flags | tr ' ' '\n' \
  | awk -F= '/InitialHeapSize|MaxHeapSize/ {printf "%s = %.1f MB\n",$1,$2/1024/1024}'

# Expect:
# -XX:InitialHeapSize = 128.0 MB
# -XX:MaxHeapSize     = 128.0 MB

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top