# Gateway / Java question 7.7.2

**URL:** <https://forum.inductiveautomation.com/t/gateway-java-question-7-7-2/10402>\
**Category:** General Discussion\
**Created:** [August 26, 2015, 8:22pm UTC](https://forum.inductiveautomation.com/t/gateway-java-question-7-7-2/10402 "2015-08-26T20:22:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 26, 2015, 8:37pm UTC](https://forum.inductiveautomation.com/t/gateway-java-question-7-7-2/10402/2 "2015-08-26T20:37:17Z")

</div>

It is normal for Ignition (and java in general) to cycle between low and high memory usage. In a nutshell, java will defer difficult garbage collection tasks until memory pressure makes it necessary. If there is a great deal of garbage objects when that happens, java will stall briefly while it frees memory. If you have tweaked anything else on your system, you are probably still running what is called the Concurrent-Mark-Sweep garbage collection algorithm (standard for java7). A new garbage collection algorithm is now available for production use in java 8 called the [Garbage First Garbage Collector](http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html), aka G1GC. This new algorithm breaks memory management into much smaller pieces, minimizing stalls when each piece is cleaned up. Stalls are still possible, but in my experience, very rare.

You can also instruct the garbage collector keep a separate log file – this can show the actual stall times and a variety of memory usage statistics.

This ignition.conf excerpt might help you get started:[code]

# Java Additional Parameters

#wrapper.java.additional.1=-XX:PermSize=3076m  
#wrapper.java.additional.2=-XX:MaxPermSize=4096m  
wrapper.java.additional.1=-XX:+UseG1GC  
wrapper.java.additional.2=-XX:MaxGCPauseMillis=100  
#wrapper.java.additional.4=-Xincgc  
wrapper.java.additional.3=-Xloggc:/var/log/ignition/javagc-%WRAPPER\_TIME\_YYYYMMDDHHIISS%.log  
#wrapper.java.additional.4=-XX:+CMSClassUnloadingEnabled  
#wrapper.java.additional.5=-XX:+CMSPermGenSweepingEnabled  
wrapper.java.additional.4=-Ddata.dir=/var/lib/ignition/data  
wrapper.java.additional.5=-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE\_CLEAR\_REFERENCES=false  
#wrapper.java.additional.8=-Xdebug  
#wrapper.java.additional.9=-Xrunjdwp:transport=dt\_socket,server=y,suspend=n,address=8000

wrapper.java.additional.6=-XX:+PrintGCDetails  
wrapper.java.additional.7=-XX:+PrintGCTimeStamps  
wrapper.java.additional.8=-XX:+PrintGCDateStamps

# Initial Java Heap Size (in MB)

wrapper.java.initmemory=1536

# Maximum Java Heap Size (in MB)

wrapper.java.maxmemory=3072  
[/code]Note that the PermSize and MaxPermSize directives are not used with G1GC (and cause problems if set with G1GC).

You might want to consider turning on the GC logging options first, then running for a few days to establish a baseline. Then switching algorithms to see the improvements.

---

_[View the full topic](https://forum.inductiveautomation.com/t/gateway-java-question-7-7-2/10402)._
