# Execute failed: Java heap space

**URL:** <https://forum.knime.com/t/execute-failed-java-heap-space/35585>\
**Category:** KNIME Analytics Platform\
**Created:** [August 25, 2021, 5:41am UTC](https://forum.knime.com/t/execute-failed-java-heap-space/35585 "2021-08-25T05:41:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [August 25, 2021, 7:22am UTC](https://forum.knime.com/t/execute-failed-java-heap-space/35585/2 "2021-08-25T07:22:39Z")

</div>

Good day @Karlygash !

On top of increasing the heap space using the entry “-Xmx” in the knime.ini file, the following actions may be taken too to improve the use of the Java heap space during execution:

1. Set the Memory Policy of the nodes that are memory consuming to “Write Tables to Disc”:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/d/6dc88894d258852ea79652cdefa6a629c0cfc376.png)

1. Use -Run Garbage Collector- or -Run Heavy Garbage Collector- node by @Vernalis before and/or after running the nodes that are memory consuming:

> **[Run Garbage Collector](https://hub.knime.com/vernalis/extensions/com.vernalis.knime.feature/latest/com.vernalis.knime.misc.gc.node.RunGarbageCollectorNodeFactory)**
>
> This node forces the JVM Garbage collector to Run, freeing up memory. It reports the amount of used memory before and after to the console log (at the INFO lev…

> **[Run Heavy Garbage Collector](https://hub.knime.com/vernalis/extensions/com.vernalis.knime.feature/latest/com.vernalis.knime.misc.gc.node.heavygc.RunHeavyGCNodeFactory)**
>
> This node runs a 'heavy' garbage collection. A number of garbage collection cycles are run. Between each collection, there is a delay, during which System.runF…

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/0/60ac6e936f9224d38134f214cb4bea6ca16a5e57.png)

For instance, in the above example, I’m flushing within a loop the heap space at the end of every iteration within a loop, which forces to clean up the heap space before executing the next loop iteration.

I guess in your case you are reading the different sheets within a loop. You could then flush the memory after reading each Excel sheet and before reading next by setting the Garbage Collector node as shown in the snapshot above.

1. KNIME is capable of running nodes in parallel, which means that they are clogging the heap space at the same time too. If you have several nodes running at the same time in your workflow, I would recommend to force them to run sequentially by connecting them with the red variable connections, for instances as follows to write several Excel files:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/1/613ee3b272c8a8f899c810e2d09c3be035041118.png)

As shown in the snapshot above, the red variable connections force the nodes to write the excel sheets sequentially. Without these connections, they would have been run in parallel.

1. Complementary information to these hints is available here too:

> **[Tuning the Performance and Scalability of KNIME Workflows | KNIME](https://www.knime.com/blog/tuning-the-performance-and-scalability-of-knime-workflows)**
>
> Want a workflow that uses available in-DB capabilities and moves to a production Spark setup? At the same time it should use special Google services before comparing a KNIME Random Forest to an H2O Random Forest and then automatically choose the...

> **[Optimizing KNIME workflows for performance | KNIME](https://www.knime.com/blog/optimizing-knime-workflows-for-performance)**
>
> KNIME provides performance extensions such as the KNIME Big Data Connectors for executing Hive queries on Hadoop, or

1. Finally you can monitor “in real time” the use of your computer resources with the Windows task monitor (as far as I remember you use Windows), if you keep it open on a corner of your monitor while executing your workflow. It should give precious information about how the workflow is using the memory in real time as it goes.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/c/9c9224f79c8e74c2b39f371cd0f5077db4419fd9.png)

Hope these hints help 😉

Good luck @Karlygash !

Best wishes,

Ael

---

_[View the full topic](https://forum.knime.com/t/execute-failed-java-heap-space/35585)._
