OutOfMemoryError – GC overhead limit exceeded
When we initially set up this application we gave it 2 gigs of ram. The server it was running on had 4 gigs of ram. It occasionally run out of memory and gave the error OutOfMemoryError – GC overhead limit exceeded. We figured that the application needed more memory so we increased the memory on the server to 8 gives and gave the application 6gb of ram. Overkill huh?
After we increase the memory I was tasked with monitoring it to see would happen. At first I thought it was it was memory leak, but the application has some reasonably good memory management tools. It allows you to see the amount of free and used memory in the JVM and it allows you to clear the caches and run GC. After a few of clearing the cache and running GC for a few days I realised that the memory usage after GC was low and stable, so I decided to look elsewhere.
I ran free -m on the server after we I got results like what are listed below.
Then it dawned on me what the problem was. The application will basically use what ever memory is available to the JVM for caching data. When we increased the memory we would delay the problem but not solved it. Java was using just over 6gs of ram and the other applications on the server were using almost all of the other 2 gigs of ram. There was not enough ram left over for the operating system to do much else and when Java wanted to garbage collect resulting in thrashing
and as a result the garbage collector spent a long time doing nothing and was not able to free .
What we should have done is maybe increase the memory on that server by 500mb to 1gb and just left the the Java memory settings as they were. I was even getting page faults when I tried to grep some relatively small files.
This entry was posted in Performance Tuning
. Bookmark the permalink