views:

52

answers:

1
+1  A: 

What I believe you see here is the concurrent Garbage Collector is doing young generation cleanups, but the heap is constantly churning so it can't get a hold of all the references for an old generation collection. When you hit the perform GC button you're doing a "stop-the-world" collection which blocks all the threads, freezing the heap, and allowing a much larger collection to occur. My main concerns here would be - does a large collection ever occur (after x hours)? Are you seeing OutOfMemory errors with a smaller heap?

1) Do you have the auto refresh button turned on? It may also be that profiler does a small GC (Eden space) before taking a snapshot.

2) This is perfectly normal. Garbage collection takes time and resources (processor cycles). If you've set your heap to a large size, it will wait until it reaches some percentage of that until triggering a garbage collection itself. I think the default free space to live object ratio is between 40% and 70% I know tomcat specifically changed the way it does garbage collection around version 5, tomcat v4 had performance issues because it spent a lot of time running the garbage collector. You may want to do some research here and see if tomcat has custom garbage collection options.

3) No. A nearly full heap is exactly what you're striving for. It may make sense to make the heap smaller so that a full garbage collection doesn't take such a long time. It's trade-off between lots of garbage collections (pauses) and lengthy garbage collections (long pauses). Each app is different, so I generally start with the defaults and tweak as needed. There are lots of options for garbage collection (and alternate collectors) if you're interested.

Java 5

Java 6 FAQ, Whitepaper

Steve Jackson
@steve, your question:does a large collection ever occur (after x hours)? ans:No, i run it without restarting tomcat for 2weeks. Q: are you seeing outofmemory errors with smaller heap? you want me to set the heap -xmx to smaller to see whether there is outofmemory?
cometta
@steve 1. ans: i'm not using profiler tab, i'm using the 'sampling' tab. by default the refresh button is on
cometta
I'm more interested in why you changed the heap size in the first place...have you seen any issues?
Steve Jackson
Also, you might want to try leaving -Xms out or set to a smaller value to see if you need that full 1GB. Or have you already determined you need a GB of heap?
Steve Jackson
no, just a wild guest i put -xms -xmx same. by the way, i already take out -xms. will update on my observation. anything else u want to comments?
cometta
now i can see gc auto run . lot different. any other tips?
cometta
@cometta - I think you're getting the hang of it. -Xmx sets that max number: you use that to ensure you don't have OutOfMemory errors. -Xms is more for performance: I know I need a lot of memory at startup and don't want to wait for the heap to grow on it's own. I rarely use that one.
Steve Jackson