title: how to configure tomcat so that classes from previous runs don't remain in memory
body: <p>On <code>tomcat/manager</code> when I click on <code>find leaks</code> button I get the following message:</p>
  
  <p>The following web applications were stopped (reloaded, undeployed), but their
  classes from previous runs are still loaded in memory, thus causing a memory
  leak (use a profiler to confirm):</p>
  
  <p>This is actually causing big problems for me because when I need to re-deploy an app with some changes, the old version remains in the server and when I try to use it I get:</p>
  
  <pre><code>IllegalStateException: Illegal access: this web application instance has been stopped already
  </code></pre>
  
  <p>Even though in tomcat/manager the application shows as started.</p>
  
  <p>How do I resolve this? I looked at <a href="https://stackoverflow.com/questions/10755836/tomcat-their-classes-from-previous-runs-are-still-loaded-in-memory">here</a> but did not solve the problem. I tried running <code>jps</code> command to get <code>pid</code> of JVM but it doesn't return the JVMs, I guess due to permissoin issue.</p>
  
  <p><strong>Is it possible to configure tomcat somehow so that when an application is undeployed, it shouldn't keep any classes of that application in the memory?</strong></p>
  
  <p>The question <a href="https://stackoverflow.com/questions/7974882/how-to-purge-tomcats-cache-when-deploying-a-new-war-file-is-there-a-config-se">How to purge tomcat's cache when deploying a new .war file? Is there a config setting?</a> is not solving my problem as I followed the steps given there:</p>
  
  <ul>
  <li>undeploy the app</li>
  <li>stop tomcat</li>
  <li>delete the app from `work` directory of tomcat</li>
  <li>clear browser cache</li>
  <li>start tomcat</li>
  <li>put the war file in `webapps`</li>
  <li>wait a few moments</li>
  <li>start the app</li>
  </ul>
  
  <p>those steps didn't solve the problem</p>