when stop my project , tomcat say :
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) .
Where we find that Which classes are left in memory ?
please help me .
When this happens, generally there is something in memory which is "pinning" the WebappClassLoader (the class loader that is responsible for loading classes for an instance of your webapp) into memory. If you re-load your webapp several times, you will be able to see the number of WebappClassLoader instances increasing by 1 for every reload that you perform. This is usually not a leak in Tomcat but instead a leak either directly in your webapp's code, a leak in a library that you use, or a leak triggered by a few specific Java API calls that do stupid things.
First, please read this: http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf. It's an excellent description of what exactly is happening.
Second, use a profiler to determine what is holding references to objects loaded by your WebappClassLoader. Lots of times, simply using a ServletContextListener can clean-up those references as the webapp is being stopped.
Third, if you find that there is a leak coming from a library you use, please let them know about it. If you find a leak coming from a class in the JRE, then look at the options for using the JreMemoryLeakPreventionListener: http://tomcat.apache.org/tomcat-6.0-doc/config/listeners.html#JRE_Memory_Leak_Prevention_Listener_-_org.apache.catalina.core.JreMemoryLeakPreventionListener. If there is no option for whatever you have found, please drop-by the Tomcat users' and let us know what's missing: we'll add it.
You can run
jmap -histo
which will show you loaded classes.For example:
Another way is to enable classloading debug information and do some scripting to detect what is left loaded.