Error Reference

MID Server Java heap space exceeded: out of memory

MID Server Java heap space exceeded: out of memory

Where this appears

This error appears in the MID Server agent.log file when the MID Server JVM runs out of allocated heap memory during processing. It commonly occurs during Discovery, Service Mapping, or other integration operations that handle large datasets or run multiple concurrent probes.

Sourdough
Chrome Extension

Debugging this in a real instance?

Sourdough lets you trace "MID Server Java heap space exceeded: out of memory" through system logs, script errors, and API health in the ServiceNow tab you are already using.

Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Cause

Default JVM heap size is insufficient for current workload processing large Discovery payloads or many concurrent probe executions. (high likelihood)

Too many Discovery or Service Mapping probes running simultaneously, consuming excessive memory per concurrent thread. (high likelihood)

Large database result sets or file transfers through the MID Server exceeding available memory allocation. (medium likelihood)

Memory leak in custom probe scripts or third-party integrations retaining object references indefinitely. (medium likelihood)

MID Server processing oversized attachment uploads or downloads that exceed heap capacity. (low likelihood)

Fix

Step 1: Stop the MID Server service and locate the wrapper.conf file in the MID Server agent/conf directory.

Step 2: Edit wrapper.conf and increase the wrapper.java.maxmemory value from default 512m to 1024m or 2048m depending on workload requirements.

Step 3: Navigate to MID Server > Servers in ServiceNow and reduce the max_threads parameter from default 20 to 10 or 15 for the affected MID Server.

Step 4: Review Discovery schedules and reduce concurrent Discovery jobs or stagger execution times to prevent overlapping memory-intensive operations.

Step 5: Check MID Server ECC Queue for stuck or repeatedly failing records that might cause memory accumulation and cancel problematic jobs.

Step 6: Start the MID Server service and monitor agent.log file for successful startup and memory allocation confirmation.

Step 7: Test Discovery or integration operations incrementally and monitor MID Server performance through MID Server > Servers status page.

Step 8: If errors persist, enable JVM garbage collection logging in wrapper.conf and analyze memory usage patterns for further optimization.

Test Your Knowledge

Quick 3-question quiz. See how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue