# Error Java Heap Size(maxmemory set at 16gb)

**URL:** <https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980>\
**Category:** Ignition\
**Created:** [February 28, 2019, 8:43pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980 "2019-02-28T20:43:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [February 28, 2019, 8:43pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980/1 "2019-02-28T20:43:09Z")

</div>

Hello, I’ve been having this error for sometime now when i open one of my windows. i will try to be as detailed as possible so please read on. and thanks in advance

I press a push button to open a new window should open. using following script, to pass two values to the new window.

```auto
  param1 = event.source.parent.getComponent('Power Table 1').runid
     param2 = event.source.parent.getComponent('Power Table 1').lineid
     linea=event.source.parent.getComponent('Power Table 1').linename

     if param1 == 0 : 
         system.gui.messageBox ("PLEASE SELECT A RUN FROM THE TABLE")
    else:
         if system.gui.confirm(u'ESTA ACCION VA A PRODUCIR PALLETS EN LA LINEA %s , DESEA CONTINUAR?' % linea, 'Confirm'):

              window = system.nav.swapTo('ProductionPallets/CreatePallettouch110118', {'runid' : param1 ,'lineid' : param2})
		      system.nav.centerWindow(window)

```

But it does not always work correctly, instead i get these 3 different scenarios scenarios are happening:

1- windows open correctly.  
2- windows does not open at all, the client freezes for about 3-4 seconds, and then logs this error.

```auto

>Writing project to cache file C:\Users\Juan\.ignition\cache\gwxxx.xxx.xxx.xxx_xxxx_xxxx_main\C0\CSJasmine.proj
Exception in thread "AWT-EventQueue-2" java.lang.OutOfMemoryError: Java heap space
	at java.lang.StringCoding$StringDecoder.decode(Unknown Source)
	at java.lang.StringCoding.decode(Unknown Source)
	at java.lang.StringCoding.decode(Unknown Source)
	at java.lang.String.<init>(Unknown Source)
	at java.io.ByteArrayOutputStream.toString(Unknown Source)
	at org.python.core.Py.getStackTrace(Py.java:980)
	at org.python.core.Py.displayException(Py.java:1106)
	at org.python.core.PyException.printStackTrace(PyException.java:79)
	at org.python.core.PyException.toString(PyException.java:98)
	at java.lang.Throwable.<init>(Unknown Source)
	at java.lang.Exception.<init>(Unknown Source)
	at com.inductiveautomation.ignition.common.script.JythonExecException.<init>(JythonExecException.java:21)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:639)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:180)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:271)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy20.actionPerformed(Unknown Source)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

```

3 - I press button once more, after the Error in the other scenario shown above and the windows opens, but the following happens:

```
    1. It opens on the background(and layer index of that window is highest in client so it should never be in behind any window)
    2. the data on the window it's grey out, like on the image below. 

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/07fb758e59d48d94e1044b7243c7db4a409c0693.png)

```
    3. There is no data being polled from the DB 
    4. The PowerTable Background color is supposed to be Alternating White/Gray but as shown all Gray. 
    5. Component next to label "SKU" its supposed to show the selected value based on the Run ID: component above.

```

When the heap size error doesn’t occur the window works just fine. it has actually been working for a while with less occurrence until yesterday.

About this window and hardware information in case it’s related to the error:

```
   * It has multiple property bindings with sql. query set at Poll Rate Off, but they all execute when windows opens first time. (10 properties are bound like that) So running at least 10 Queries when window opens.
   * Pass in two properties as shown in script above from previous window.
   * Windows has 23 expressions bindings .
   * 3 Expression bindings have now(0) in them for different calculation. 
   * When window opens no other error in the log.
   * Client Memory 1gb, ( i can increase to more if needed)
   * Workstations running the Client in Windows, all have from 8GB RAM and up to 16GB
   * Gateway in Server 2016, 64GB ram. Ignition wrapper conf. set as below.

```

```auto

# Wrapper Java Properties
# ********************************************************************
# Java Application
# Locate the java binary on the system PATH:
wrapper.java.command=C:\Program Files\Java\jdk-10.0.1\bin\java.exe
# Specify a specific java binary:
#set.JAVA_HOME=/java/path
#wrapper.java.command=C:\Program Files\Java\jdk-10.0.1\bin\java.exe

# Tell the Wrapper to log the full generated Java command line.
#wrapper.java.command.loglevel=INFO

# Java Main class. This class must implement the WrapperListener interface
# or guarantee that the WrapperManager class is initialized. Helper
# classes are provided to do this for you. See the Integration section
# of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=lib/wrapper.jar
wrapper.java.classpath.2=lib/catapult.jar

# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=lib

# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE

# Java Additional Parameters
wrapper.java.additional.1=-XX:PermSize=64m
wrapper.java.additional.2=-XX:MaxPermSize=128m
#wrapper.java.additional.3=-XX:+UseConcMarkSweepGC
wrapper.java.additional.4=-XX:+CMSClassUnloadingEnabled
#wrapper.java.additional.5=-XX:+CMSPermGenSweepingEnabled
wrapper.java.additional.6=-Ddata.dir=data
wrapper.java.additional.7=-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

# Initial Java Heap Size (in MB)
wrapper.java.initmemory=4096

# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=16384

# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=com.inductiveautomation.catapult.Catapult

wrapper.shutdown.timeout=120
wrapper.jvm_exit.timeout=120

# Set this value to TRUE to allow ignition.conf to be reloaded when the JVM is restarted
wrapper.restart.reload_configuration=TRUE

```

Again thanks for the help.

---

<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:** [February 28, 2019, 8:49pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980/2 "2019-02-28T20:49:00Z")

</div>

The memory settings shown are for the gateway. You are running out of memory in the client. What are the client memory settings in the project properties? What does the memory usage graph look like in the client diagnostics windows?

---

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [February 28, 2019, 8:57pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980/3 "2019-02-28T20:57:14Z")

</div>

Thanks for the quick response, like i mention please read on information it’s there.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/de6b9f6f6a2a784584c3e2c97f6a4827ff8f88c9.png)

Client Memory set at 1GB.

Graph

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/33422403be82c9327c31413d9dfe4fb2b3fc4fd7.png)

client in this workstation it’s in STAGING and has been update multiple times since last open.

clients on the other works stations, memeory usage it’s much less. Project Name : Jasmine

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/47b459290571c589d53aad9d6ab002e32cf2ce44.png)

any other details let me know.

---

<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:** [February 28, 2019, 9:08pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980/4 "2019-02-28T21:08:02Z")

</div>

It’s not clear why that project uses so much more memory that the others, but it is. Based on the graph, it is occasionally hitting 1GB and therefore dying. Increase the client memory allotment.

Also consider adding the following to your native client launcher’s command line for this (or all) of your projects:

```auto
 jvm-args="-XX:+UseG1GC"

```

---

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [February 28, 2019, 9:12pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980/5 "2019-02-28T21:12:38Z")

</div>

i’ll try but i have been doing thins since 256MB increasing and not been solved.

and what does the code you provided do ? and where would it put it?

---

<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:** [February 28, 2019, 9:41pm UTC](https://forum.inductiveautomation.com/t/error-java-heap-size-maxmemory-set-at-16gb/22980/6 "2019-02-28T21:41:29Z")

</div>

> [@juang](#):
>
> and what does the code you provided do ?

It switches the garbage collector to a better algorithm. It uses a bit more CPU time, but keeps memory usage lower, usually. The graph of memory usage, over a long enough time period, shows a steady increase until it approaches maximum, then a cleanup is done, and the graph starts climbing again. G1GC makes this happen faster, and cleans up more reliably. I've found that everything runs most efficiently if the trough of the graph is \<50% of max, and the peak of the graph is \<80% of max.

You put that setting on the command line in your desktop shortcut for the project, as created by the native client launcher for your platform.
