Java heap space, shutting down error

Hi everyone,

I come across an error with the JVM Heap size as →

[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] ]

However, after the debugging it was found that it was caused due to the length() function that we were using to count the number of records in a .csv file

can someone please help me understanding why a length() function would cause a JVM OOM ?

I’m using Gatling 3.3.1 version.

Are you sure the cause is not that you’re using readRecords (and that’s where you’re using length)?
readRecords loads the data in memory.

Yes, thats correct Stephane , Im using the length() function inside the readRecords() e.g. val abc = records.readRecords.length → here ‘records’ has the csv associated.

however, when i increased the JVM to 2 gigs it still failed and thrown the same error. is there a solution that we can use to get away this issue ?

Appreciate your quick response and assistance.

If you’re using Java 8, expect a heap memory footprint of at least twice the size of the file.
If you don’t want to stop using readRecords and count the number of lines yourself, you have to increase the size of the heap.