java – OutOfMemoryError: GC overhead limit exceeded при параметрах -Xmx8192M -XX:-UseGCOverheadLimit

Question:

jUnit tests work with large amounts of data, in particular, this error occurs when we read data from the database into an object.

RAM – 16 GB, 4 virtual processors

when the error occurred

java.lang.OutOfMemoryError: GC overhead limit exceeded
at sun.reflect.GeneratedConstructorAccessor47.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)

then I added the -XX:-UseGCOverheadLimit but got the following error:

java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.lang.reflect.Field.copy(Field.java:150)
    at java.lang.reflect.ReflectAccess.copyField(ReflectAccess.java:144)
    at sun.reflect.ReflectionFactory.copyField(ReflectionFactory.java:309)
    at java.lang.Class.copyFields(Class.java:3115)
    at java.lang.Class.getFields(Class.java:1557)
    at main.java.DataFormat.DbTable.loadObjectFromResultSet(DbTable.java:101)
    at main.java.DataFormat.DbTable.getEntities(DbTable.java:57)

all JVM options -Xmx8192M -XX:-UseGCOverheadLimit

at the time the error appeared, the following system parameters were: RAM is stable at 46% (7400MB), CPU 77% -82% (82% at the time of the error)

tell me how to fix this problem?

Sparvka

  1. java.lang.OutOfMemoryError: GC overhead limit exceeded

This error can occur both when the first and second areas are overflowed. It is connected with the fact that there is little memory left and the GC is constantly working, trying to free up some space. This error can be disabled using the -XX: -UseGCOverheadLimit parameter, but, of course, you should not disable it, but either solve the memory leak problem, or allocate more space, or change the GC settings.

Answer
String object is too heavy. and I have a lot of thongs there. For example, we calculated a file that weighs 250 MB, has 1600 characters per line and 220,000 lines. I fill in ArrayList<String> lines , where each line is written as an object of 250 fields that take a value of 1600 characters. Such an object weighed a little over 6Гб .

Solution: increased the memory to 14Гб . now the problem is that the 6GB object does not fit on the heap, you have to think something else and sacrifice the test execution time.

Answer:

In this case, the error java.lang.OutOfMemoryError: GC overhead limit exceeded indicates that you are trying to process such an amount of data that does not fit into memory. In the help you provided, it is mentioned that an error is thrown when the memory area occupied only by the created objects overflows. Plus, you can see in the stack trace that your classes (

at main.java.DataFormat.DbTable.loadObjectFromResultSet(DbTable.java:101)
at main.java.DataFormat.DbTable.getEntities(DbTable.java:57)

) at the time of receiving the error, they are trying to unload data from the database.

Therefore, test the simple and disappointing conclusion from the above on a smaller amount of data or allocate a larger amount for unloading data (-Xmx12000M) if they fit there, then the error will disappear. It is useless to configure garbage collection in this case. The GC will not be able to remove the loaded objects because they are still in use.

Scroll to Top