views:

73

answers:

2

Heap memory size thrashes between 2gigs and ~8gigs about once a minute (see picture).

Relevant details:

  • High traffic site
  • Lots of physical memory
  • Redhat 5.5
  • Java 1.6.0_07
  • Glassfish 2.2.1 (yes, I know it's old. no, we can't upgrade. yes, i know it's unusual to use as a production app server).
  • -XX:MaxPermSize=192m -XX:+AggressiveHeap -Xms14336m -Xmx14336m

I have little experience with memory tuning, but it seems like MaxPermSize is out of whack with Xms and Xmx. Or is this normal?

jConsole heap thrashing

+8  A: 

Why does my JVM heap size thrash from 2gigs to 8 gigs?

There is no evidence that the system is thrashing in the normal (harmful) sense. The sawtooth pattern indicates that objects are being allocated (the up slope) and the GC is then reclaiming them. The allocation rate seems a bit high, but there is every sign that the GC is running efficiently. Indeed, the fact that the heap size is always dropping back to ~2Gb is a good sign, as is the fact that the % CPU usage is low.

I have little experience with memory tuning, but it seems like MaxPermSize is out of whack with Xms and Xmx. Or is this normal?

It looks kind of normal.

Certainly, there's no need to increase the size of permGen. (PermGen is used for objects that are anticipated to never be garbage collected; typically intern'd Strings and code segments. Normal application objects are never allocated in or moved to permGen space.)

(Hypothetically, if you didn't have lots of memory, the high allocation rate might be a cause for concern. However, you cannot address that by tweaking the GC parameters. You'd need to do some profiling to see what is creating so many objects and see if it is sensible to try to reduce the creation rate. Depending on the application, it may not even be sensible to try.)

Stephen C
I would almost expect this sort of thing in a high-traffic webserver environment. Each page load causes memory to be allocated, and it doesn't de-allocate until garbage collection. I don't see any reason to think this isn't normal.
Erick Robertson
MaxPermSize controls the amount of memory available for *permanent* objects – ones that are unlikely to be garbage collected ever – for example class definitions. It is unrelated to normal garbage collection operations.
Bill Michell
@Bill - exactly.
Stephen C
A: 

very normal. all java programs have memory pattern like that.

irreputable