OutOfMemoryError in console mode

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… 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:

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

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

2 Likes

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?

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.

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

-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

-Xmx4096m

or

-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.

1 Like

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

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

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

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

-Xmx16400m

In KS, you can monitor the heap status:

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

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

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.

@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

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?

@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 (9.5 KB)

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

Could you make sure you allocated -Xmx8192m?

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!!!

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.

1 Like

I have found out that the com.kazurayam.materials.imagedifference.ImageCollectionDiffer class contained in the ver 0.74.0 of Materials library 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.


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.. In this version I fixed a OutOfMemoryError: Java Heap Space problem as described at 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:

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

And in the commandline, you want to do:

$ 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

-Xms512m
-Xmx4096m
1 Like