Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Embedded Jetty class loading issues

I run Jetty embedded and I am attempting an upgrade from Jetty 5 (I know, old) to Jetty 7.  One of the issues I have always had inside my application is memory leaks (heap and perm gen) when restarting Jetty instances.  Any of the digging I have done in the past has shown what I think to be references to the classloader where the Jetty instance is running.  Part of the issue has been some of my application classes are being loaded in the wrong class loader so I am trying to sort that out.

I have started with a very basic stripped down instance of org.eclipse.jetty.server.Server that only has a connector installed, nothing else.  One thing I found is org.eclipse.jetty.util.ShutdownThread (I built JARs from an SVN snapshot) registers a shutdown hook.  Even if I set Server.setStopAtShutdown( false ), ShutdownThread still has a shutdown hook registered.  This has a reference into my classloader and prevents the classloader from being garbage collected even after I shutdown the Jetty instance.  As a hack, I did this when Server.stop() is called:

Runtime.getRuntime().removeShutdownHook( org.eclipse.jetty.util.thread.ShutdownThread.getInstance() );
org.eclipse.jetty.util.thread.ShutdownThread.getInstance().setContextClassLoader( null );

and it cleans up everything so my classloader can be garbage collected.  Since I am managing the life cycle of the Server instance, can anything be done with the ShutdownThread so it won't register the shutdown hook (ShutdownThread.buttOut())?

The second issue I have noticed that is killing me is JspServlet which I know the Jetty folks are not responsible for.  If I add a WebAppContext handler to my Server instance, the Jasper code keeps a ton of references around the prevents the classloader from being garbage collected.  At this point, I am not 100% certain what it is holding on to but, it appears to be all of the Log instances that are used for internal logging.  I am still digging on this one and maybe I just need to move logging into my classloader but, does anyone have any experience with this where you could provide some hints about how I can tell Jasper to shutdown clean?

Thanks for the help.
Tony
 
This message (and any associated files) is intended only for the
use of the individual or entity to which it is addressed and may
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient
you are hereby notified that any dissemination, copying or
distribution of this message, or files associated with this message,
is strictly prohibited. If you have received this message in error,
please notify us immediately by replying to the message and deleting
it from your computer. Messages sent to and from Stoneware, Inc.
may be monitored.


Back to the top