We have Java portal application. We use Hibernate as ORM tool for that.
Recently we have been observing lot of memory leaks. Perm Gen would fill up and the application would die.
After few weeks of research and fixing the code we were able to fix 70% of memory leaks.
For the remaining 30%, after lot of trial and error we figured out that only when we execute native queries in hibernate on JBoss server we faced this issue. When I run my application on TomCat I don't see any issue.
Here is the relevant code which is creating this issue