views:

134

answers:

3

This is the output after running for around 10 minutes.

Heap
 PSYoungGen      total 7040K, used 0K [0x24060000, 0x247c0000, 0x26790000)
  eden space 6528K, 0% used [0x24060000,0x24060000,0x246c0000)
  from space 512K, 0% used [0x246c0000,0x246c0000,0x24740000)
  to   space 512K, 0% used [0x24740000,0x24740000,0x247c0000)
 ParOldGen       total 48896K, used 43303K [0x06990000, 0x09950000, 0x24060000)
  object space 48896K, 88% used [0x06990000,0x093d9d80,0x09950000)
 PSPermGen       total 12288K, used 3737K [0x02990000, 0x03590000, 0x06990000)
  object space 12288K, 30% used [0x02990000,0x02d366c0,0x03590000)
[GC [PSYoungGen: 0K->0K(7040K)] 43303K->43303K(55936K), 0.0005129 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[Full GC (System) [PSYoungGen: 0K->0K(7040K)] [ParOldGen: 43303K->43303K(48896K)] 43303K->43303K(55936K) [PSPermGen: 3737K->3737K(12288K)], 0.1964557 secs] [Times: user=0.36 sys=0.00, real=0.19 secs]

Thanks in advance

A: 

My advice is don’t try to tune GC. JVM will handle it.

Upul
+1  A: 

I'd recommend using something like JConsole (JDK 1.5+) or jVisualVM (JDK1.6). A single output of printgc is not enough to give a good recommendation.

There are usually two issues: You create too many new Objects, the New Generations fills up quickly and thus the gc moves all those objects to the Survivor Space or even Perm Generation. If this is what happens (they get deleted with the next full gc, which takes longer), I'd recommend to increase the Young/New generation. (-XX:NewSize). This allows the Objects to get unreferenced and deleted by a regular gc.

If you do have many long lived objects, I'd check if that is really necessary. This might mean you have to change code.

Keep in mind, that a large heap takes longer to gc compared to a small heap.

phisch
Thanks for the comment. But in the output I notice that the current Young generation space is not utilized at all..so am not sure how increasing this will help. I will check out the other tools you have mentioned.
Guru
+1  A: 

If you're running out of memory the problem is not GC, the problem is that you are using too many objects and not releasing them.

The last time I worried about Java's GC was in 1998.

EJP