title: Reason for PermGen OutOfMemoryError when "No GC root found"?
body: <p>I fix 3 different <code>PermGen</code> <code>OutOfMemoryError</code> issues in webapp and it survives any number of redeploys (I don't try larger then 30) in restricted <code>-XX:MaxPermSize=66m</code>. Running application takes ~55 MB of <code>PermGen</code>.</p>
  
  <p>Main reason to fix memory leaks is to practice and to make development environment more pleasant - with <code>&lt;Context reloadable="true"&gt;</code> after compilation my webapp have been redeployed after 3 sec!</p>
  
  <p>Just now I have found error in <code>catalina.out</code>:</p>
  
  <pre><code>Dec 26, 2015 5:28:09 PM org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor run
  SEVERE: Unexpected death of background thread ContainerBackgroundProcessor[StandardEngine[Catalina]]
  java.lang.OutOfMemoryError: PermGen space
  
  Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" 
  Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]"
  </code></pre>
  
  <p>As usual I run <code>visualvm</code> and run OQL:</p>
  
  <pre><code>select unique(map(heap.objects('java.lang.ClassLoader'), 'classof(it)'))
  </code></pre>
  
  <p>and review <code>org.apache.catalina.loader.WebappClassLoader</code> instances. What I actually do can be described by OQL:</p>
  
  <pre><code>filter(heap.objects('org.apache.catalina.loader.WebappClassLoader'),
                      'it.state.name.toString() == "DESTROYED"')
  </code></pre>
  
  <p>That one instance doesn't freed <code>PermGen</code> memory. But when I invoked <em>find nearest GC root</em> I get <strong>No GC root found</strong>.</p>
  
  <p>What is the reason for <code>PermGen OutOfMemoryError</code> when <code>No GC root found</code>?</p>
  
  <p>Is that possible that reason for <code>OutOfMemoryError</code> is processing application requests during redeploy?</p>
  
  <p>I make especially low <code>PermGen</code> to force GC in PermGen during application redeploy, because <code>PermGen</code> cleaned only on memory pressure - I decide to monitor if OutOfMemoryError still effects my app.</p>