Skip to main content

ThreadState during GC

2 replies [Last post]
Joined: 2007-11-05

I'm investigating odd CPU spikes we're experiencing in our J2EE app running on Glassfish. When it happens, I notice that there are full GC's running back to back to back and the server becomes non-responsive. I've also been taking jstack dumps during these periods and noticed that most worker threads at this point have the ThreadState: BLOCKED (on object monitor). So, my question is:

Is it normal to see many threads in ThreadState: BLOCKED (on object monitor) during a full GC? If not, is there a usual or common ThreadState during full GCs?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-06-19

Agreed, this sounds like a memory (or lack of memory) problem. A recent article on Developer works may prove useful to you:

It applies to Windows as well and also discusses ways of detecting heap memory uses. Also have you considered using JConsole or a profiler such as VisualVM (comes with Java1.6_07+) to look for places where excess memory usage may be throttling the GC?

Joined: 2005-11-01

If you are getting a Full GC back to back, it sounds like you don't have a high enough maximum memory size or you have a memory leak.

It is very likely for your threads to hang while a full GC is running, this can include being in a BLOCKED state.