I doing my first investigating on a potential memory leak likely causing my server to halt. I see the following from the logs:
...
6676.590: [GC [PSYoungGen: 61432K->3902K(65408K)] 343313K->308460K(384896K), 0.0153165 secs] [Times: user=0.07 sys=0.10, real=0.02 secs]
6684.493: [GC [PSYoungGen: 65406K->3900K(67200K)] 369964K->319251K(386688K), 0.0104186 secs] [Times: user=0.07 sys=0.04, real=0.01 secs]
6684.503: [Full GC [PSYoungGen: 3900K->0K(67200K)] [PSOldGen: 315351K->256886K(333824K)] 319251K->256886K(401024K) [PSPermGen: 70248K->70248K(116736K)], 0.5965072 secs] [Times: user=0.60 sys=0.00, real=0.60 secs]
6692.773: [GC [PSYoungGen: 63296K->1160K(62976K)] 320182K->258046K(396800K), 0.0043468 secs] [Times: user=0.04 sys=0.00, real=0.00 secs]
...
What confuses me is, in which generation should I be looking for a memory leak? all? individually or simultaneously?
You only need to look in the PSOldGen after a Full GC. Objects which are retained for any length of time will be in there. i.e. you don’t need to worry about short lived objects when looking for a leak.
If you believe you have a leak, take a look at
jmap -histo:liveto see which objects are being retained most. You can do a full dump withjmap -dump:live,format=b,file={filename}to see why these objects are being retained. You can load this file with VisualVM. (You can also use VisualVM to trigger the heap dump)