Heap Space issue in flow

ARAVINDA11
Tera Contributor

@Ankur Bawiskar  @Community Alums  @Sohail Khilji  @Maik Skoddow  or anyone please help

 

How can I solve the Heap size issue 

 

what is the maximum memory size is allowed in MID SERVER

5 REPLIES 5

AJ-TechTrek
Giga Sage
Giga Sage

Hi @ARAVINDA11 ,

 

Lets Understanding MID Server Heap Size Issue-


* The MID Server runs as a Java application (Java Virtual Machine – JVM).
* By default, the JVM heap size is limited (often 256 MB – 512 MB, depending on the OOTB config).
* Heavy Discovery jobs, multiple probes/sensors, or integrations (like Orchestration / Cloud Discovery) can cause OutOfMemoryError: Java heap space.

 

How to Solve Heap Size Issues as per my understanding -


1. Increase MID Server Heap Size
You can tune the JVM memory allocation for the MID Server:


1. On the MID Server host, go to:
<MID Server Install Dir>/agent/conf/wrapper-override.conf
2. 
(If wrapper-override.conf does not exist, copy from wrapper.conf).
3. Add or update these lines:
wrapper.java.maxmemory=2048
4. wrapper.java.initmemory=512
* initmemory = Initial heap size (MB).
* maxmemory = Maximum heap size (MB).
6. Example:
* Small workloads: 1024 MB
* Medium workloads: 2048 MB
* Large-scale Cloud Discovery: 4096 MB
7. Restart the MID Server service.

 

2. Tune Thread Settings
* Too many concurrent probes can overwhelm memory.
* Adjust in MID Server Configuration (instance > MID Server record > Capabilities/Properties):
* mid.max_threads
* mid.probe.batch.size
* Lowering concurrency reduces heap spikes.

 

3. Distribute Load Across Multiple MID Servers
* Don’t overload one MID Server.
* Use clusters and assign discovery schedules to spread jobs.
* For large Discovery jobs (Cloud, VMware, etc.), use dedicated MIDs.

 

4. Monitor Heap Usage
* Check agent.log and wrapper.log under:
<MID Server Install Dir>/agent/logs
* Look for OutOfMemoryError.
* Use OS monitoring tools (Windows Performance Monitor, Linux top/free).

 

Maximum Memory Allowed
* Technically, the max depends on:
* OS architecture (32-bit vs 64-bit).
* Installed Java version.
* 64-bit Java + OS: up to 4–8 GB heap is safe (though rarely needed above 4 GB).
* ServiceNow recommends max 4096 MB (4 GB) unless you have extreme workloads.

 

Recommended Best Practice
* Start with 2048 MB heap.
* If you still hit OOM errors, scale horizontally (add more MID Servers) instead of infinitely increasing heap.
* Use dedicated MIDs for heavy probes (Cloud, DB, Orchestration).

 

Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
 

Thank You
AJ - TechTrek with AJ - ITOM Trainer
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
Topmate:- https://topmate.io/aj_techtrekwithaj (Connect for 1-1 Session)
ServiceNow Community MVP 2025