Kumar112
Kumar112

Reputation: 224

Running tests parallelly gives java heap out of memory.

Running tests parallel gives java heap out of memory. But when I run them not parallel, there is no memory issues. This is the error- [java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:3332) at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448) at java.lang.StringBuilder.append(StringBuilder.java:136)

Upvotes: 1

Views: 3746

Answers (4)

Corleone
Corleone

Reputation: 43

I had to turn off my logs (karate 0.9.6):

karate.configure('report', { showLog: false});

This is already fixed in karate 1.0.0

Upvotes: 1

Peter Thomas
Peter Thomas

Reputation: 58058

Yes, try to increase the heap space: https://stackoverflow.com/a/16969122/143475

Also you could reduce the number of parallel threads. It sounds like you are trying to use too many.

EDIT: this problem was fixed in v0.8.0

EDIT2: Karate 1.0 should be greatly improved

Upvotes: 1

Sudheer Singh
Sudheer Singh

Reputation: 654

This is happening because you are doing parallel execution and karate gives huge logs, make the below changes and make parallel thread 1,2 or max 3.

  <root level="info">
   <!--<appender-ref ref="STDOUT" />-->
    <appender-ref ref="FILE" />
  </root>

Upvotes: -1

rvelaz
rvelaz

Reputation: 593

Whenever an object is created the object is allocated memory from Heap, when the object is not needed any more the memory goes back to Heap space. If tests are run in parallel there will be different threads adding objects to the heap simultaneously, and you run out of heap space. When you run them single threaded, once a test finishes its objects are removed from the heap, therefore there's space in the heap for the objects in the following test.

To fix it try to increase the heap space used to run the tests.

Upvotes: 2

Related Questions