-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

On 4/21/2009 5:50 PM, Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
>> Subject: Re: Headstart on "Resolving OOM-PermGen errors on webapp
>> reload"
>>
>> Can you observe your heap and which ClassLoaders are still hanging
>> around? You might want to check to see how many
>> org/apache/catalina/loader/WebappClassLoader objects are still "live".
>> In my web application, just after a Tomcat startup, I have 2 instances
>> of this class, both of which are "live".
> 
> "Live" is a critical attribute here - unless a full GC (or two) is
> done, unused classes and classloaders will still be present.  Use
> JConsole to trigger GCs, if needed.

I haven't forced any full GCs (jconsole can't connect since I didn't
enable JMX when I started my server) but I only see 2 live
WebappClassLoaders (and 2 dead ones) after running this command:

for x in 1 2 3 4 5 ; \
   do echo running ; \
   touch lib/log4j-1.2.15.jar ; \
   ant quick-install ; \
   sleep 20s ; \
done

(Each touch/quick-install triggers an application reload)

Before my stress test, this was the output of 'jmap -heap':

(Hmm... didn't realize I was using -client in development... I should
fix that!)

Attaching to process ID 11255, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_13-b05

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 67108864 (64.0MB)
   NewSize          = 655360 (0.625MB)
   MaxNewSize       = 4294901760 (4095.9375MB)
   OldSize          = 1441792 (1.375MB)
   NewRatio         = 12
   SurvivorRatio    = 8
   PermSize         = 8388608 (8.0MB)
   MaxPermSize      = 67108864 (64.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 4128768 (3.9375MB)
   used     = 1943672 (1.8536300659179688MB)
   free     = 2185096 (2.0838699340820312MB)
   47.0763191344246% used
Eden Space:
   capacity = 3670016 (3.5MB)
   used     = 1606928 (1.5324859619140625MB)
   free     = 2063088 (1.9675140380859375MB)
   43.785313197544646% used
- From Space:
   capacity = 458752 (0.4375MB)
   used     = 336744 (0.32114410400390625MB)
   free     = 122008 (0.11635589599609375MB)
   73.40436662946429% used
To Space:
   capacity = 458752 (0.4375MB)
   used     = 0 (0.0MB)
   free     = 458752 (0.4375MB)
   0.0% used
tenured generation:
   capacity = 54755328 (52.21875MB)
   used     = 20156272 (19.222518920898438MB)
   free     = 34599056 (32.99623107910156MB)
   36.81152635959007% used
Perm Generation:
   capacity = 32505856 (31.0MB)
   used     = 23190896 (22.116561889648438MB)
   free     = 9314960 (8.883438110351562MB)
   71.343748031124% used

After the test, I get this:

Attaching to process ID 11255, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_13-b05

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 67108864 (64.0MB)
   NewSize          = 655360 (0.625MB)
   MaxNewSize       = 4294901760 (4095.9375MB)
   OldSize          = 1441792 (1.375MB)
   NewRatio         = 12
   SurvivorRatio    = 8
   PermSize         = 8388608 (8.0MB)
   MaxPermSize      = 67108864 (64.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 3604480 (3.4375MB)
   used     = 1326112 (1.264678955078125MB)
   free     = 2278368 (2.172821044921875MB)
   36.79066051136363% used
Eden Space:
   capacity = 3211264 (3.0625MB)
   used     = 1004312 (0.9577865600585938MB)
   free     = 2206952 (2.1047134399414062MB)
   31.274663185586736% used
- From Space:
   capacity = 393216 (0.375MB)
   used     = 321800 (0.30689239501953125MB)
   free     = 71416 (0.06810760498046875MB)
   81.83797200520833% used
To Space:
   capacity = 393216 (0.375MB)
   used     = 0 (0.0MB)
   free     = 393216 (0.375MB)
   0.0% used
tenured generation:
   capacity = 47677440 (45.46875MB)
   used     = 40365360 (38.49540710449219MB)
   free     = 7312080 (6.9733428955078125MB)
   84.66343830541237% used
Perm Generation:
   capacity = 34078720 (32.5MB)
   used     = 33963000 (32.38964080810547MB)
   free     = 115720 (0.11035919189453125MB)
   99.66043325570914% used

I'm a little confused... the "configuration" seems to indicate that I've
got an 8MB PermGen space, but then the Permanent Generation says it's
32.5MB.

Let's try to force a full GC by using System.gc() from a little JSP
file. Here's the heap description afterward:

Attaching to process ID 11255, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_13-b05

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 67108864 (64.0MB)
   NewSize          = 655360 (0.625MB)
   MaxNewSize       = 4294901760 (4095.9375MB)
   OldSize          = 1441792 (1.375MB)
   NewRatio         = 12
   SurvivorRatio    = 8
   PermSize         = 8388608 (8.0MB)
   MaxPermSize      = 67108864 (64.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 3604480 (3.4375MB)
   used     = 357840 (0.3412628173828125MB)
   free     = 3246640 (3.0962371826171875MB)
   9.927645596590908% used
Eden Space:
   capacity = 3211264 (3.0625MB)
   used     = 357840 (0.3412628173828125MB)
   free     = 2853424 (2.7212371826171875MB)
   11.143275669642858% used
- From Space:
   capacity = 393216 (0.375MB)
   used     = 0 (0.0MB)
   free     = 393216 (0.375MB)
   0.0% used
To Space:
   capacity = 393216 (0.375MB)
   used     = 0 (0.0MB)
   free     = 393216 (0.375MB)
   0.0% used
tenured generation:
   capacity = 47677440 (45.46875MB)
   used     = 17904184 (17.07476043701172MB)
   free     = 29773256 (28.39398956298828MB)
   37.55273773088488% used
Perm Generation:
   capacity = 20185088 (19.25MB)
   used     = 20101336 (19.170127868652344MB)
   free     = 83752 (0.07987213134765625MB)
   99.58507983715504% used

... and checking for WebappClassLoader objects after that shows 2 live
WebappClassLoaders none dead. Looks like my webapp is clean, at least
when it first comes up.

We don't have any weird stuff like Quartz, etc. and all our caching is
done using Maps in the application scope or within a webapp-loaded class.

I also have a pair of ServletContextListeners that shut down JULI and
log4j as appropriate (if they're been loaded by the webapp and not a
parent). I'm not sure if they actually help (and it doesn't matter since
we never bounce our application in production without also bouncing
Tomcat itself.

I'd love some help interpreting the heap info I see above.

Thanks!
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknuR4sACgkQ9CaO5/Lv0PAnRgCgjHrQWJsj4hDG2ys9OcXE8ftf
8p8AoIVhWdvPJSTpldVCmsolEQe6K8wq
=DW+t
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to