13

I have a method which hits DB and fetches lot of records into memory for processing. After I fetch the records and before I start processing, I get the following log message. What does it mean ?

164575.034: [GC (Allocation Failure)  4937664K->3619624K(5602816K), 0.0338580 secs]

Options:

java.opts=-d64 -Xmx8g -XX:+PrintGCTimeStamps -verbose:gc -XX:MaxPermSize=512m -XX:+UseParallelGC -XX:+UseParallelOldGC
Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
dumper
  • 485
  • 2
  • 8
  • 18
  • 3
    It looks like it means it started a GC due to an allocation failure i.e. it ran out of space in the current generation. Which platform are you using? – Lee May 25 '14 at 18:35
  • What are your JVM arguments ? – Vipin May 25 '14 at 18:37
  • java.opts=-d64 -Xmx8g -XX:+PrintGCTimeStamps -verbose:gc -XX:MaxPermSize=512m -XX:+UseParallelGC -XX:+UseParallelOldGC – dumper May 25 '14 at 19:53
  • 1
    Does batching of fetching & processing records help? – dumper May 25 '14 at 19:55
  • possible duplicate of [Java Garbage Collection Log messages](http://stackoverflow.com/questions/895444/java-garbage-collection-log-messages) – Gilles 'SO- stop being evil' May 25 '14 at 20:09
  • 7
    This message says “Allocation Failure”. Not “GC failure”. Your program tried to allocate memory. This failed because there was too little memory available, so the garbage collector ran, and it freed some memory. – Gilles 'SO- stop being evil' May 25 '14 at 20:10
  • You can increase the amount of memory to the JVM with the -Xms and -Xmx switches. But maybe you need to fetch the records in smaller batches instead? Are you keeping any references to objects unnecessarily? – Matt Coubrough May 25 '14 at 20:42
  • duplicate of http://stackoverflow.com/questions/28342736/java-gc-allocation-failure – ruediste Jan 25 '16 at 07:12

1 Answers1

12

It just basically tells you that it had to run GC to allocate additional memory, it does not fit in memory otherwise. So it is just a reason for GC.