While debugging perm-gen issues with an application that uses EJB3.1 singleton
and JPA, it was found that GFFileHandler.recentErrors holds on
to the last four LogRecords. If one of the LogRecords was a result of a
application-defined Throwable/Exceptionm, the LogRecord holds a reference to the
application-defined Exception class and the Exception class inturn hold on to
classloader (WebappClassLoader) preventing them from GC'ed, eventually resulting
in a PermGen space issue.
To reproduce the issue:
- deploy and undeploy the app referred to in issue 12368
- Perform a GC and analyze the heap using a tool like Eclipse Memory Analzer,
the path from the WebappClassLoader (of the app that has been undeployed) to a
GC root. [see attached image for the relevant Eclipse Memory Analyzer tool
output where a HibernateException, that is part of the Hibernate library bundled
wiht the application, is held on to by the GFFileHandler.recentErrors Queue].
Please remove caching of the LogRecords or prevent holding of a strong reference
to a user defined class.