Description
If you receive this error, the Java Virtual Machine (JVM) has exhausted its heap memory. It means that the JVM is spending extensive time and effort to free up memory using the Garbage Collector (GC).
If it spends 98% of its time performing GC and only reclaims 2% or less of the heap space, then this error will be thrown to indicate that it is not functioning as expected.
What Causes This Error?
This can be due to not having enough heap memory allocated. An incorrect configuration in GenRocket can also cause it. Here are some common reasons for receiving this error when using GenRocket to generate test data:
- Generator parameters that limit the amount of data that can be generated, such as a unique limit.
- Loading a big file into memory with a Generator when there is insufficient RAM to store it.
- Reading a bulk load of data, such as a database query, into memory when there is insufficient RAM to store it.
Possible Solutions
1. JAVA_OPTS Environment Variable
Make sure the JAVA_OPTS environment variable is set up and configured correctly. Learn more by reading the Runtime setup instructions here.
JAVA_OPTS = -Xms1024m -Xmx2048m
2. Check Generator Configurations
Some Generators have unique parameters that limit the number of values that can be generated.
When set to 'true,' they require that the Generator has enough space to generate all the needed values. If uniqueness is exhausted, you might receive this error.
You can change the parameter to 'false' if the values do not have to be unique. If the generated values must be unique, you can do so with a different Generator (#3 below) or increase the JVM heap size (#4 below).
3. Use a Different Generator (Large Files or Bulk Data)
You may receive this error when there is insufficient space for loading a large file or bulk data into memory.
Generators that read data from outside sources can fill up RAM and result in an error. We recommend using a different Generator that loads data as batches.
For example, the ListCSVGen reads the whole file into memory, and an error will be received when there is not enough space to bring that large file into RAM. In this case, you can use the CSVToMapGen to read the CSV file in batches rather than the whole file at one time.
Similarly, QueryBeforeLoopV2Gen can read a bulk load of data from the database into memory. If there is insufficient space, it will cause this error as well.
4. Increase the JVM Heap Size
In the example below, -xmx4g sets the heap size to 4 GB:
JAVA_OPTS="-Xms512m -Xmx4g