how to know jvm is stopping the world?

Stefan Karlsson stefan.karlsson at
Mon Dec 12 15:06:28 UTC 2011

On 12/11/2011 07:31 AM, Li Li wrote:
> hi,
>     In our application of full text searching with lucene and solr. we 
> will give jvm about 25GB memory. we use CMS as old generation garbage 
> collector. But the jvm sometimes can't do anything. So our clients 
> complain that the connection is time out. we find the reason is the 
> jvm is doing full gc and it will stop service for about 1-3 seconds.
>     I know that this situation is inevitable when using CMS collector. 
> but we have more than one searching machines, so if I know jvm is 
> doing full gc(specially stop the world), I can send requests to other 
> machines. But the question now is that jvm don't provide an api for 
> that. I think it's not very difficult(for guys developing hotspot, but 
> is in deed difficult for me ). So I want your help.
>     The first question is where is the position of CMS full gc.
>     from
>     there are many steps:
>       1. STW initial mark
>       2. Concurrent marking
>       3. Concurrent precleaning
>       4. STW remark
>       5. Concurrent sweeping
>       6. Concurrent reset
>     there are 2 stop the world stages. I want to know the line 
> number(or functions) of this stages. so I can tell java program that 
> jvm now is doing full gc.
>      The second is that how to communicate between jvm and java 
> program? My expected thing is like :
>      //java program
>      if(System.isStopTheWolrd()){
>            //system is busy, tell the dispatch node that don't send 
> request to me
>      }else{
>            do service;
>      }
>      I have no experience in jvm developing. jvm is implemented in c 
> and jni is the interface between them. is there any other method that 
> jvm can achieve this? obviously, it can extend System class and add a 
> static method named isStopTheWorld(). Could some one tell me how to do 
> this in details? Thank you very much.

You could probably use JVMTI. See:


More information about the hotspot-gc-dev mailing list