# OutOfMemoryError in console mode

**URL:** <https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559>\
**Category:** Integrations\
**Tags:** azure, integrations, katalon-studio\
**Created:** [March 27, 2020, 12:53am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559 "2020-03-27T00:53:03Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 27, 2020, 12:53am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/1 "2020-03-27T00:53:03Z")

</div>

Hi all,  
We use Katalon Studio with Runtime Engine License and run it in azure DevOps.

My test get `OutOfMemoryError` in azure DevOps pipeline, but I can run it in my local / VM.  
I saw the solution of changing `katalon.ini` file like as [this](http://http://forum.katalon.com/t/html-reports-taking-hours-to-generate-because-katalon-takes-automatic-screenshots/25936/2)… but I run my test in azure DevOps, so I think I cannot change the ini file in katalon task at the same time, right?

Is there any solution?

FYI : My test includes comparison of large screenshots. So it show OutOfMemory even if I reduced the number of test cases to run at once.  
Anyway, it can be run in my local, so I think it is memory problem.

Error:

```auto
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: Java heap space

```

---

<div class="post-metadata">

**Author:** ![huynguyen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/huynguyen/32/552_2.png) [@huynguyen](https://forum.katalon.com/u/huynguyen)\
**Post date:** [March 27, 2020, 4:10pm UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/2 "2020-03-27T16:10:43Z")

</div>

Hi @rie.ota,  
Please define VM arguments to increase heap size as instructed in the document at [https://docs.katalon.com/katalon-studio/docs/execution-settings.html#allow-editing-jvm-parameters-in-execution-settings](https://docs.katalon.com/katalon-studio/docs/execution-settings.html#allow-editing-jvm-parameters-in-execution-settings)

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 12:17am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/3 "2020-03-30T00:17:02Z")

</div>

Hi, @huynguyen,  
I think the feature requires “Katalon Studio Enterprise” license, right?  
We have KRE but not KSE…  
I cannot edit Execution \> Launch Arguments setting although I use 7.2.9.

Isn’t there another solution?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 1:48am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/4 "2020-03-30T01:48:13Z")

</div>

You do not need KSE license to increase the size of memory allocated for a KRE runtime.

On my windows 10 desktop, I installed Katalon Studio (not Enterprize) in `%USER_PROFILE%\Katalon_Studio_Windows_64-7.2.1`.  
In that directory I find a plain text file named `katalon.ini`.

 ![katalon.init](https://europe1.discourse-cdn.com/katalon/original/2X/b/b5c3f5994f728fd63cc2720ee8be455da433d3ba.png)

In the `katalon.ini` file, I can find a line like

```auto
-Xmx2048m

```

This means my test runs with maximum memory for JVM of 2048 Mega bytes.

With a plain text editor like VIM or Emacs, I can edit this line to

```auto
-Xmx4096m

```

or

```auto
-Xmx8192m

```

The appropriate memory size would depend on how much your tests want and how much physical memory size the machine has.

@rie.ota

You run your test on Azure DevOps. Hopefully you know how to edit the katalon.ini file and configure the machine image on which your tests run.

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 2:20am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/5 "2020-03-30T02:20:52Z")

</div>

Hi @kazurayam, and thank you for the easy to understand explanation.

I just tried to following procedure and failed with same OutOfMemory…something wrong?

log saids `INFO: Total memory: 7167 MB`

1. Run katalon task with “executable tests” (then KRE is installed to the Windows OS on azure DevOps pipeline)
2. Next powershell task : replace “-Xmx2048m” to “-Xmx4096m” in `katalonc.ini` (← KRE use katalonc.ini instead katalon.ini)
3. Run katalon task with pre-installed KRE
4. OutOfMemory

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 2:23am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/6 "2020-03-30T02:23:47Z")

</div>

Why not you replace to “-Xmx8192m” instead of “-Xmx4096m”?

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 2:31am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/7 "2020-03-30T02:31:57Z")

</div>

sorry for the lack of information… I tried both of “-Xmx8192m” and “-Xmx4096m”

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 2:36am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/8 "2020-03-30T02:36:27Z")

</div>

You can try even larger memory size, if the device suffice, for example

```auto
-Xmx16400m

```

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 3:21am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/9 "2020-03-30T03:21:18Z")

</div>

In KS, you can monitor the heap status:

> [@Heap Memory Issue when try to execute Testsuite collection](http://forum.katalon.com/t/heap-memory-issue-when-try-to-execute-testsuite-collection/40766/3):
>
> You can also monitor the heap: [image] This will produce a heap status monitor in the KS status bar: [image] You can click the trashcan button to help release memory back to the pool. Also, remember to clear out old runtime logs: [image]

Looking at the heap status, you would find how much memory your tests actually require.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 3:28am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/10 "2020-03-30T03:28:21Z")

</div>

> [@rie.ota](#):
>
> log saids `INFO: Total memory: 7167 MB`

In which file you find this info? I have never seen this type of log.

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 3:35am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/11 "2020-03-30T03:35:04Z")

</div>

> In KS, you can monitor the heap status:

Thank you for the information, I will check it.

> In which file you find this info?

It is from azure Pipeline. From the beginning of the katalon task in azure Pipeline, I saw the log and I think it is the machine info.

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 4:52am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/12 "2020-03-30T04:52:02Z")

</div>

@kazurayam  
I run my test suite with Heap Memory settings and I got following value. I think it is not big…  
 ![“ss” 2020-03-30 at 13.50.48](https://europe1.discourse-cdn.com/katalon/original/2X/7/75da78c9b4bd3cf39b4d99d6753e8be560e63a87.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 5:06am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/13 "2020-03-30T05:06:02Z")

</div>

360M is not big at all.

You need to go back to the error log and try to find out at which stage of processing you got the error  
`org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: Java heap space`.

Could you share the log file here?

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 5:25am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/14 "2020-03-30T05:25:24Z")

</div>

@kazurayam  
Thank you. Actually the test is from yours (Thanks as always)  
In the part of “ImageDiff\_chronos”. I run my test with big screenshots… My test failed when examining 2.9MB png.  
(Anyway it succeeds in my local and use only 360M)  
[stdout.log](https://forum.katalon.com/uploads/short-url/wAW51yLPVEJZiGCIFMWwEJ92ANE.log) (9.5 KB)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 5:54am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/15 "2020-03-30T05:54:02Z")

</div>

Allocating sufficient size of -Xmx\*\*\*\* should resolve this issue.

Could you make sure you allocated -Xmx8192m?

---

<div class="post-metadata">

**Author:** ![rie.ota](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rie.ota/32/20464_2.png) [@rie.ota](https://forum.katalon.com/u/rie.ota)\
**Post date:** [March 30, 2020, 5:59am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/16 "2020-03-30T05:59:32Z")

</div>

> [@kazurayam](#):
>
> -Xmx16400m

You are right, this seems to have been resolved. (Just now, for the first time, it has passed in the pipeline.) Thank you for your kindness!!!

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 30, 2020, 6:09am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/18 "2020-03-30T06:09:16Z")

</div>

```auto
2020-03-30 03:49:44 - [TEST_CASE][ERROR] - Test Cases/Exam_capture/ImageDiff_chronos_biguser: Test Cases/Exam_capture/ImageDiff_chronos_biguser FAILED.
Reason:
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: Java heap space
	at com.kazurayam.visualtesting.ImageDiffer.invokeMethod(ImageDiffer.groovy)
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
	at ImageDiff_chronos_biguser.run(ImageDiff_chronos_biguser:13)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
	at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
	at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
	at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
	at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
	at TempTestSuite1585539994136.run(TempTestSuite1585539994136.groovy:36)
Caused by: java.lang.OutOfMemoryError: Java heap space
	at ru.yandex.qatools.ashot.comparison.PointsMarkupPolicy.addDiffPoint(PointsMarkupPolicy.java:41)
	at ru.yandex.qatools.ashot.comparison.ImageDiff.addDiffPoint(ImageDiff.java:51)
	at ru.yandex.qatools.ashot.comparison.ImageDiffer.markDiffPoints(ImageDiffer.java:81)
	at ru.yandex.qatools.ashot.comparison.ImageDiffer.makeDiff(ImageDiffer.java:57)
	at ru.yandex.qatools.ashot.comparison.ImageDiffer$makeDiff.call(Unknown Source)
	at com.kazurayam.materials.imagedifference.ImageDifference.makeImageDiff(ImageDifference.groovy:47)
	at com.kazurayam.materials.imagedifference.ImageDifference.<init>(ImageDifference.groovy:38)
	at com.kazurayam.materials.stats.StorageScanner.makeImageDelta(StorageScanner.groovy:391)
	at com.kazurayam.materials.stats.StorageScanner$makeImageDelta$5.callCurrent(Unknown Source)
	at com.kazurayam.materials.stats.StorageScanner.makeMaterialStats(StorageScanner.groovy:276)
	at com.kazurayam.materials.stats.StorageScanner$makeMaterialStats$2.callCurrent(Unknown Source)
	at com.kazurayam.materials.stats.StorageScanner.makeStatsEntry(StorageScanner.groovy:173)
	at com.kazurayam.materials.stats.StorageScanner.scan(StorageScanner.groovy:137)
	at com.kazurayam.materials.stats.StorageScanner$scan$1.call(Unknown Source)

```

This stacktrace impies that the image comparison algorithm of AShot library is NOT designed memory-efficient. It may consume super large heap memory for pixel-wise comparison. — just I guess. All we can do now is to allocate bulky -Xmx\*\*\*\*, I think.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 1, 2020, 12:59pm UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/19 "2020-04-01T12:59:08Z")

</div>



---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 15, 2020, 7:57am UTC](https://forum.katalon.com/t/outofmemoryerror-in-console-mode/41559/20 "2020-06-15T07:57:50Z")

</div>

I have found out that the `com.kazurayam.materials.imagedifference.ImageCollectionDiffer` class contained in [the ver 0.74.0 of Materials library](https://github.com/kazurayam/Materials/blob/0.74.0/src/main/groovy/com/kazurayam/materials/imagedifference/ImageCollectionDiffer.groovy) has a bug: a sort of memory-leak.

I am sure that this bug caused OutOfMemoryError occured to @rie.ota

I will fix this problem soon and release an update.

* * *

> [@kazurayam](#):
>
> This stacktrace impies that the image comparison algorithm of AShot library is NOT designed memory-efficient.

I was wrong in blaming AShot. Sorry about that.

My Groovy code had a bug.

* * *

I have updated the VisualTestingInKatalonStudio project to the version [1.17.3.](https://github.com/kazurayam/VisualTestingInKatalonStudio/releases/tag/1.17.3). In this version I fixed a OutOfMemoryError: Java Heap Space problem as described at [StorageScanner object uses too large memory for buffering a lot of BufferedImages · Issue #17 · kazurayam/Materials · GitHub](https://github.com/kazurayam/Materials/issues/17)

If you have any project using the VisualTestingInKatalonStudio, you can easily update the framework to the latest version. In your project, you have `build.gradle` file, right? You change the `vt.version` as follows:

```auto
plugins {
  id "com.github.kazurayam.visualtestinginks" version "0.1.21"
}
vt.version = '1.17.3'

```

And in the commandline, you want to do:

```auto
$ cd $yourVisualTesingProject
$ ./gradlew enableVisualTesting

```

then, all the code and libraries of “VisualTestingInKatalonStudio” will be automatically updated. The change from 1.17.3 requires no changes required to your test case scripts.

In the $KatalonStudioInstalledDirectory/katalon.ini file, you specify the maximum heap space allocated to Java VM of Katalon Studio. I would recommend you to write in the `katalon.ini`

```auto
-Xms512m
-Xmx4096m

```
