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.

 

 

 
  total used free shared buffers cached
Mem: 8192 8172 19 0 178 1445

 

 

 
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.

9 Responses to OutOfMemoryError – GC overhead limit exceeded

  1. admin says:

    We discovered today that we are not closing http connections in one of our helper classes. This might be the cause of the problem. So it may have been a memory leak after all.

    • Tassilyn says:

      I touhght I’d have to read a book for a discovery like this!

      • Edgar says:

        oh man.. I can’t tell how much do I enjoy these discussions. These are both fun, as well as lniighteneng.Here is something that I grabbed from net, that pretty well explains how memory optimization works: If you have just run an intensive or specifically large application or game, you know about that groggy feeling your system can have. That’s usually because of the leftovers taking up your valuable memory. You can free it, however, by clicking your heels together 3 times and saying: Let my memory go. Er, I mean, using a program to free that trapped memory. There are many good programs to do this at Tweakfiles.If you don’t want to download a big fancy program, you can actually make one yourself very easily using Visual Basic runtimes (you don’t even need VB to do this).Here’s what you do: Open up Notepad (Start, Run, notepad (OK)). Depending on how much memory you have, put the appropriate values in Under 128mb Ram: Mystring = (16000000)128mb or More: Mystring = (80000000)Save it as Memory.vbe (including the quotes!). Close as many programs as you can, then run (double click) this handy little script to free your memory whenever your computer is feeling sluggish.If you have trouble running it, you may need the Visual Basic Runtimes. You can get them here.All this does is allocate a chunk of memory while the script is running, and then the VB runtimes deallocate it. The Value needs to be set according to the amount of memory you have (i.e. it will probably need increasing in order to be effective if you have 1Gb), but forces any currently unused memory to be paged to the swapfile, thus freeing that memory in order to be used by the rest of the system. i.e. if you are working on a large image file in PSP and then minimize PSP, you can temporarily regain physical memory by swapping currently unused ram out to the pagefile.It does actually work (I did some benchmarks when I was implementing it in my tweaking program), but whether it is particularly of use is another issue. This is exactly what I use such memory optimization programs for do get rid of the hangover effect after I had been running some heavy application.Regarding Defrag, I am going to agree with you in principle, with a small caveat. All my readings around this indicate that Windows automatically takes care of Defragging RAM whenever it reboots. So, it is not required on the computers that are regularly rebooted, but if some system is running for quite some time, this manual defragmentation can be helpful.Waiting to be enlightened further.

  2. Ened says:

    We dcisovered today that we are not closing http connections in one of our helper classes. This might be the cause of the problem. So it may have been a memory leak after all.

    • Neeha says:

      Instructions were great one caution, when piunttg the case side back, the tabs fold over (and subsequently break off) rather easily, at least one of mine did on the front side top the other 5 tabs and 2 screws still hold the side very securely.Also, I had purchased an eee Box and an eee 1000HE (together for the cost of one \”normal\” PC) and upgraded the memory in the 1000HE from 1GB to 2GB, thinking I would be slick and put the 1GB stick from the 1000HE in my eee Box. My eee Box came with a single 1GB stick marked 667MHz, the stick from the 1000HE is marked 1GB 2Rs16 PC2-5300S-555-12-A3, long story short, the eee Box would not boot with both sticks in (didn\’t try the 1000HE memory in there alone ) Oh well, so much for a cheap upgrade.

  3. Amelia says:

    A better magazine theme would make the blog nicer.:)

  4. If you want to get social bookmarking backlinks that will help skyrocket your website search engine ranking straight to the top, check out this site http://socialbookmarksubmission.org/

Leave a Reply to Adriana Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>