1

After submitting ~300 requests through a web service and getting responses back for validation, I am getting 'Java Heap Space' error. Each of these web service responses are about 1 MB in size.

I've narrowed the root cause down to be these large service responses, but how do I work around or resolve this? I have tried the below action items already with no success based on researching this issue:

  • Updated to karate 9.6
  • Updated to Java 11
  • Increased memory size
  • Reduced logging (debug to info, etc)

The same thing happens for a different web service where each response is about 50 KB in size, though it took longer for it to run out of memory. It ran out towards the end after 800 orders:

1823874 [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default) on project mvrinteractive: An exception occured while executing the Java class. Java heap space -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default) on project mvrinteractive: An exception occured while executing the Java class. Java heap space

trincot
  • 317,000
  • 35
  • 244
  • 286
David A
  • 37
  • 3
  • If you get an error after so many requests, then you may have a memory leak somewhere in your code – areus Jan 28 '21 at 14:43
  • For future readers - upgrading to newer versions helped, and Peter also suggested this piece of code which helped quite a lot: * string response = responseBytes – David A Sep 21 '21 at 19:17

1 Answers1

1

Please (please) try the 0.9.9.RC3 version. And please create an example along the lines here so we can investigate if needed: https://github.com/intuit/karate/issues/1394#issuecomment-751252092

Hopefully the new / dev version is an improvement. Else we can look at a simulation (you help us with) and figure out an option, e.g. we have to change our code to use streams, or switch off logs.

Also do look at this interesting option: https://stackoverflow.com/a/64352676/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thank you Peter. Running into some issues with downloading dependencies on 0.9.9.RC3 but working on that and will see if it helps. – David A Jan 28 '21 at 20:38
  • @DavidA yes I should have given you this link: https://github.com/intuit/karate/wiki/1.0-upgrade-guide – Peter Thomas Jan 29 '21 at 05:42