Resolving java.lang.OutOfMemoryError: GC overhead limit exceeded?

Why you’re getting this error?

It’s an alert from JVM and this generally means that, for some reason, the GC spends excessive amount of time – by default, 98% of the total CPU time spent for the process – and is able to recover very little memory – less than 2% of the heap.

What to do to resolve this exception?

If you’re executing your own code, you’ve got a tough job at hand – to review your code.

1. You’re probably creating lots of temporary objects in a loop; See if created object(s) can be reused.
2. If it’s a genuine requirement, try increasing the max heap size (XmX) in JVM arguments.

I don’t want JVM to throw this alert. Can I disable it?
You can turn this off with the command line option -XX:-UseGCOverheadLimit

More on this here:

One comment

  1. The one time I got this problem it was because the server that I was one did not have a lot of extra physical memory left over so it was trashing and not freeing up enough memory quickly enough. You might want to add physical memory to the machine if the other suggestions don’t work.

    More information about my experience with this is here

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: