Reputation: 205
I have an application which on startup runs two or three full GC. There is lot of heap space and there is no need to run any GC(minor or full). However on gc log, i can see the permgen getting filled up and immediately after that a full GC is run.After this, there is an increase in permgen space. Eventually , once all classes are loaded, there is no full GC any more.
My question is if permgen gets filled up, does the VM run GC to claim some memory from heap and add extra memory to permgen? or does it throw OutOfMemory-permgen?
Upvotes: 2
Views: 2141
Reputation: 719396
My question is if permgen gets filled up, does the VM run GC to claim some memory from heap and add extra memory to permgen? or does it throw OutOfMemory-permgen?
The GC will run a full GC in an attempt to free up some memory in the permgen space. If that fails to free up enough space, a OOME will be thrown saying the permgen is full.
No current or past HotSpot JVMs will attempt to increase permgen beyond its prescribed limit, whether or not there is normal heap space to allow this.
The reasons that a full GC needs to happen before the OOME (permgen) are:
Permgen objects are (AFAIK) usually immutable, so changes in reachability due to permgen object mutation are unlikely.
Upvotes: 3
Reputation: 4054
It will throw OOM-permgen if the PermGen size hits your -XX:MaxPermGen limit (or the default).
Upvotes: 0