0

I have memory leak problem on DatabaseField class. It consumes more and more memory and never releases any memory during gc operations. Everytime we launch stress test, it keeps 20mb memory after 2 week it crashes my server.

What is the interaction between this class and Garbage Collector.

Ali Arda Orhan
  • 764
  • 2
  • 9
  • 24

2 Answers2

1

You must use a tool to analyse them memory heap like VisualVM or MAT but, anyway, this is hard to solve.

Here you have an answer about it and this post tell you how use VisualVM to catch it.

Good luck! (you'll need it ;-) )

Community
  • 1
  • 1
jmvivo
  • 2,653
  • 1
  • 16
  • 20
1

Looks like you posted this to the EclipseLink mailing list with a bit more information, but still not enough to tell what the problem is. Many tools have the ability to track down what is holding onto an object so it can't be GCd; if you track down the DatabaseField I'm betting you'll find a problem in your application that is causing the leak.

In my experience, the most common cause of memory leaks when using JPA has been application caching entities read from different EntityManagers. As these Entities have references to the context that read them, they prevent the EntityManager from being GC'd, which also keeps its internal objects and caches from being GC'd. The solution is to not cache entities in your application - they are already cached in JPA, so you are duplicating the memory usage without getting the benefit of having changes made through the app updated in the application's cache. Just store the entity's ID and use a find call to retrieve it when needed. If caching must be used, you can use read-only queries to retrieve the entities for caching, described here: http://docs.oracle.com/cd/E27559_01/doc.1112/e28552/toplink.htm

Chris
  • 20,138
  • 2
  • 29
  • 43