[ http://mc4j.org/jira/browse/STS-279?page=comments#action_10476 ] Greg Hinkle commented on STS-279: ---------------------------------
I've seen this before. A good solution would be to switch to WeakHashMap. Should immediately fix the problem as long as nothing else is holding a reference to the class. Now, because Method objects have a reference to their classes, you'll also need to wrap/unwrap the values in the map with WeakReferences. e.g. map.put(clazz, new WeakReference(methodsArray)); > Memory leak in DispatcherHelper > ------------------------------- > > Key: STS-279 > URL: http://mc4j.org/jira/browse/STS-279 > Project: Stripes > Issue Type: Bug > Reporter: Jay Paulsen > Assigned To: Tim Fennell > > The private static Map customValidations in DispatcherHelper is never > cleared. Since the key to the map entries are Class objects, when a stripes > web application is reloaded, this causes the web application classloader to > be pinned in memory and it and all the classes it loaded are never garbage > collected. > I found this with version 1.4 of stripes and tomcat 5.5.17. The > DispatcherHelper code in 1.4.1 looks the same so I imagine the same problem > will happen with this version as well. > As a temporary work around, I placed the following code in the > contextDestroyed method of a ContextListener class for my web application: > Field f = DispatcherHelper.class.getDeclaredField("customValidations"); > f.setAccessible(true); > Map<Class, Method[]> customValidations = (Map<Class, Method[]>) > f.get(DispatcherHelper.class); > customValidations.clear(); > It would be nice if stripes exposed a clear method for this field on the > DispatcherHelper class so a web app doesn't have to resort this hacked > reflection work-around, or better yet, if Stripes had a way to clean it up > itself. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://mc4j.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Stripes-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-development
