OutOfMemoryError: Java Heap issue:

Hi Team,

I am running into this “java.lang.OutOfMemoryError: Java heap space” error.

I am generating 250,000 tokens(JSON Web token in the format BEARER long sting) for user authentication and storing them in s string array to use for my simulation. I have 2 simulations for those I need two 250,000 user token arrays.

First array is generated correctly and while generating tokens for second array it fails with the above memory error.

`

29-Apr-2019 13:47:37 java.lang.OutOfMemoryError: Java heap space

`

build 29-Apr-2019 13:47:37 Dumping heap to java_pid3964.hprof …

build 29-Apr-2019 13:47:44 Heap dump file created [1095268976 bytes in 7.267 secs]

error 29-Apr-2019 13:47:45 Uncaught error from thread [GatlingSystem-scheduler-1]: Java heap space, shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[GatlingSystem]

error 29-Apr-2019 13:47:45 java.lang.OutOfMemoryError: Java heap space

error 29-Apr-2019 13:47:45 at akka.actor.LightArrayRevolverScheduler$$anon$3.nextTick(LightArrayRevolverScheduler.scala:269)

error 29-Apr-2019 13:47:45 at akka.actor.LightArrayRevolverScheduler$$anon$3.run(LightArrayRevolverScheduler.scala:235)

error 29-Apr-2019 13:47:45 at java.lang.Thread.run(Thread.java:748)

build 29-Apr-2019 13:47:45 13:47:45.028 [ERROR] i.g.a.Gatling$ - Run crashed

build 29-Apr-2019 13:47:45 java.lang.OutOfMemoryError: Java heap space

build 29-Apr-2019 13:47:45 at java.math.BigInteger.leftShift(BigInteger.java:2468)

build 29-Apr-2019 13:47:45 at java.math.BigInteger.oddModPow(BigInteger.java:2830)

build 29-Apr-2019 13:47:45 at java.math.BigInteger.modPow(BigInteger.java:2603)

build 29-Apr-2019 13:47:45 at sun.security.rsa.RSACore$BlindingParameters.getBlindingRandomPair(RSACore.java:417)

build 29-Apr-2019 13:47:45 at sun.security.rsa.RSACore.getBlindingRandomPair(RSACore.java:443)

build 29-Apr-2019 13:47:45 at sun.security.rsa.RSACore.crtCrypt(RSACore.java:178)

build 29-Apr-2019 13:47:45 at sun.security.rsa.RSACore.rsa(RSACore.java:122)

build 29-Apr-2019 13:47:45 at sun.security.rsa.RSASignature.engineSign(RSASignature.java:175)

build 29-Apr-2019 13:47:45 at java.security.Signature$Delegate.engineSign(Signature.java:1210)

build 29-Apr-2019 13:47:45 at java.security.Signature.sign(Signature.java:582)

build 29-Apr-2019 13:47:45 at io.jsonwebtoken.impl.crypto.RsaSigner.doSign(RsaSigner.java:56)

build 29-Apr-2019 13:47:45 at io.jsonwebtoken.impl.crypto.RsaSigner.sign(RsaSigner.java:43)

build 29-Apr-2019 13:47:45 at io.jsonwebtoken.impl.crypto.DefaultJwtSigner.sign(DefaultJwtSigner.java:45)

build 29-Apr-2019 13:47:45 at io.jsonwebtoken.impl.DefaultJwtBuilder.compact(DefaultJwtBuilder.java:322)

build 29-Apr-2019 13:47:45 at utilities.JWTUtility.createJWT(JWTUtility.java:85)

`

`

This test is running on a windows server VM. We run the test using mvn gatling:test -Dgatling.simulationClas………

I tried adding ENV variables for JAVA_OPTS, MAVEN_OPTS —didn’t work

I tried setting the memory using set JAVA_OPTS, MAVEN_OPTS commands - didn’t work

When I analyzed the heap file using eclipse memory analyzer, it said my string array with token is the culprit.

Is there a way to increase the memory for this test? We are using scala-maven-plugin and gatling-maven-plugin.

Any help is appreciated. I have spent enough time and not able to resolve it.

Thanks

Did you try adding a jvmArg of -Xmx to the configuration of the Gatling maven plugin?

See here: https://gatling.io/docs/current/extensions/maven_plugin/#configuration

Thanks a lot Guillaume for your reply.

That did work.

If anyone with same issue, Below is the change i made in my pom.xml under ‘gatling-maven-plugin’

`

-Xmx2000m

`

Once again thank you for the help.