Palworld Field guide

Memory leak fix: Palworld auto-restart and monitoring

Mitigate Palworld dedicated server memory leaks on Unreal Engine 5: RSS usage monitoring and graceful auto-restart via RCON upon threshold breach.

Memory leak fix: Palworld auto-restart and monitoring

The Palworld dedicated server runs on Unreal Engine 5 and suffers from progressive memory fragmentation. Due to incomplete garbage collection of despawned actors, dropped item physics states, and pal AI navigation routines, the PalServer-Linux-Test binary continually increases its resident memory footprint over 8 to 24 hours of uptime.

Without administrative intervention, memory consumption reaches 100% of host capacity, prompting the Linux kernel OOM Killer to terminate the process abruptly with SIGKILL (exit code 137). This ungraceful termination risks corrupting the Level.sav database and reverting player inventories. This guide demonstrates how to configure a lightweight memory watchdog that monitors RAM thresholds and invokes graceful RCON shutdowns before crashes occur.

Memory leak mechanics: why Palworld requires scheduled restarts#

Within Unreal Engine 5, certain entity allocation paths do not release memory pages back to the operating system efficiently. Under an active workload of 10–15 concurrent players, a Palworld instance often consumes between 16 and 32 GB of RAM within 12 hours of booting.

Audit the actual Resident Set Size (RSS) allocated to the process:

bash
ps -o pid,rss,%mem,command -C PalServer-Linux-Test

The RSS column indicates physical memory utilized in kilobytes. As this value approaches total system capacity, the instance enters a high-risk failure state.

Check whether the Linux OOM Killer has previously terminated the engine:

bash
dmesg -T | grep -E "(Out of memory|killed process.*PalServer)"

Executing graceful save sequences via RCON#

Never restart a live Palworld daemon using kill -9 or immediate systemd service stops. If players are moving inventory slots or capturing pals when the process is killed, file write buffers desynchronize.

Trigger a safe two-stage shutdown sequence over RCON:

bash
rcon -a 127.0.0.1:25575 -p "ADMIN_PASSWORD" "Save"
rcon -a 127.0.0.1:25575 -p "ADMIN_PASSWORD" "Shutdown 60 Server_restarting_due_to_memory_maintenance"

The Save directive forces disk commit of active world transactions, while Shutdown 60 displays an in-game broadcast and safely flushes state over a 60-second grace window.

Implementing a threshold-based memory watchdog script#

Rather than rebooting on a rigid schedule (which risks disrupting players during active dungeon runs), implement a dynamic memory watchdog script. It triggers restarts only when RAM saturation exceeds a defined threshold (e.g., 85%).

Create /opt/scripts/palworld-watchdog.sh:

bash
cat << 'EOF' | sudo tee /opt/scripts/palworld-watchdog.sh
#!/usr/bin/env bash
set -euo pipefail

THRESHOLD=85
CURRENT_MEM=$(free | awk '/Mem:/ {printf("%d"), $3/$2 * 100}')
RCON_PASS="ADMIN_PASSWORD"

if [ "$CURRENT_MEM" -gt "$THRESHOLD" ]; then
    echo "Memory usage at ${CURRENT_MEM}% exceeds ${THRESHOLD}%. Triggering graceful restart."
    rcon -a 127.0.0.1:25575 -p "$RCON_PASS" "Broadcast Server_restarting_in_60s_Memory_cleanup" || true
    rcon -a 127.0.0.1:25575 -p "$RCON_PASS" "Save" || true
    rcon -a 127.0.0.1:25575 -p "$RCON_PASS" "Shutdown 60" || true
    sleep 70
    sudo systemctl restart palworld
else
    echo "Memory usage normal: ${CURRENT_MEM}%."
fi
EOF
sudo chmod +x /opt/scripts/palworld-watchdog.sh

Scheduling periodic evaluation with a systemd timer#

Execute the watchdog evaluation every 15 minutes using native systemd timer units.

Define the oneshot service unit:

bash
cat << 'EOF' | sudo tee /etc/systemd/system/palworld-watchdog.service
[Unit]
Description=Palworld Memory Watchdog
After=network.target

[Service]
Type=oneshot
ExecStart=/opt/scripts/palworld-watchdog.sh
User=root
EOF

Define the timer unit:

bash
cat << 'EOF' | sudo tee /etc/systemd/system/palworld-watchdog.timer
[Unit]
Description=Run Palworld Memory Watchdog every 15 minutes

[Timer]
OnBootSec=10min
OnUnitActiveSec=15min
Persistent=true

[Install]
WantedBy=timers.target
EOF

Enable and start the timer:

bash
sudo systemctl daemon-reload
sudo systemctl enable --now palworld-watchdog.timer
systemctl list-timers palworld-watchdog.timer

Now, when memory fills up during peak traffic, the server broadcasts an alert, safely commits state, and executes a clean restart before the kernel invokes OOM termination.

For commercial hosting environments and large community networks, automated memory monitoring and graceful daemon self-healing are managed natively within an integrated server management platform, removing the overhead of custom bash scripts.

Sources#