Memory management on Glassfish

拥有回忆 提交于 2019-12-19 04:57:30

问题


I have several background tasks running on my Glassfish server implemented by @TimerService instances. The goal of these services is to extract data from files and insert that data into the database.

I tried initially to do this in JPA but the system stalled far to easily, I have now converted the process to JDBC which is far more responsive. However there are still enormous memory leaks somewhere along the way which I cannot pinpoint.

Each file is extracted in a method which manages its own transactions (1 file = 1 transaction). I would think that once this method finalises all variables loose scope and be GC'ed, but this is not the case. After a very short time I am experiencing OutOfMemoryException.

I am wondering if, how, and why Glassfish would be keeping reference to my variables (which are very heavy objects). What settings or methodologies can I apply to minimize these memory leaks?

For reference I am using the stock Glassfish settings with a couple of modifications :

-XX:+CMSPermGenSweepingEnabled 
-XX:+CMSClassUnloadingEnabled 
-XX:MaxPermSize=256m
–XmX1024m

回答1:


You might be dealing with a class loader leak. JAXB can do this when you're unmarshalling. To find out for sure you should use a memory analyzer. I highly recommend using the Eclipse Memory Analyzer Tool. Just follow a few of the tutorials and you should be able to get it figured out.



来源:https://stackoverflow.com/questions/10992294/memory-management-on-glassfish

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!