开发者

hibernate - session monitor tool

please tell me is there anytool to monitor hibernate sessions in case of session leakage

开发者_Python百科

Thank you.


You can enable Hibernate statistics to see the number of open and closed sessions: hibernateConfiguration.setProperty(Environment.GENERATE_STATISTICS, "true") Then use SessionFactory.getStatistics() to look at open and closed sessions. That should tell you if you are leaking sessions.

Finding out where the leak is coming from is another issue. I've done that by centralizing all the code to get a session and then storing a stack trace with every session open (by thread) and removing it when the session closes. Periodically, look at the list of open sessions and whichever ones are left are the leaked ones. Profiling tools can make this easier if you can reproduce the leak in a controlled environment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜