Garbage Collection - multiple sequential full gcs produces OutOfMemoryError
Posted on 2005-05-06
I am recieving an OutOfMemoryError in my tomcat logs. I've done a bit of research, tuned parameters, logged gc etc. What I have found is that the OutOfMemoryErrors occur when the garbage collector does several back-to-back full garbage collections. Below is the output from turning on the -Xloggc flag.
45058.932: [GC 241734K->226138K(257164K), 0.0406180 secs]
45069.840: [Full GC 242134K->64082K(257164K), 1.1170640 secs]
45075.677: [GC 79503K->65708K(246232K), 0.0513280 secs]
46517.803: [GC 189661K->189569K(246232K), 0.0840740 secs]
46518.033: [GC 219496K->219434K(246232K), 0.0876900 secs]
46518.287: [Full GC 245984K->168803K(246232K), 1.5587820 secs]
46519.978: [GC 185245K->184869K(260160K), 0.1363050 secs]
46520.281: [GC 204247K->203053K(260160K), 0.1215160 secs]
46520.524: [GC 219385K->218914K(260160K), 0.1191330 secs]
--> 46520.902: [Full GC 245053K->225597K(260160K), 1.8996470 secs]
--> 46523.039: [Full GC 257946K->257356K(260160K), 0.6038950 secs]
--> 46523.673: [Full GC 260144K->259881K(260160K), 1.3549970 secs]
--> 46525.028: [Full GC 259881K->259881K(260160K), 0.4633640 secs]
--> 46525.555: [Full GC 260159K->35411K(260160K), 0.5106320 secs]
46531.403: [GC 51602K->37156K(260160K), 0.2099900 secs]
46533.591: [GC 53348K->37075K(260160K), 0.0421670 secs]
Somewhere during the highlighted [Full GC...] lines, I get at least one OutOfMemoryError. Because the garbage collector often runs a single time and brings the memory usage down to around 64M (see second line of output above), I believe that my real required memory is in that range, I currently have Xmx set to 256m (Could having this set so high actually be causing the problem?). There are 4G of RAM on the machine.
Java version information:
# java -version
java version "1.4.1_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)
-XX:PermSize=256m -XX:MaxPermSize=256m -Xmx256m -Xloggc:gc.log
(PermSize and MaxPermSize are being set because at one point, we believed
the source of the OutOfMemoryError might actually be Perm space, however,
the addition of these settings has not changed the behavior. Is there a flag
similar to -Xloggc which will give me information about the Perm space?
All of the tools that I have seen thus far are for java 5 and above).
Any insight appreciated.