解决这个问题的正确方法显然是追溯到问题的根本原因,并修复代码中的泄漏.解决问题的快速而肮脏的方法只是重新启动Tomcat(或者您正在使用的任何servlet容器).
这是我的三个问题:
>假设您通过跟踪问题的根本原因(内存泄漏)来选择解决问题,您将如何收集数据来放大问题?
假设您选择快速而肮脏的方式,只需重新启动容器即可,您将如何收集数据以选择最佳重启循环?
>您是否能够在长时间内部署和运行项目,而无需重新启动servlet容器来重新获得缓冲?或者偶尔的servlet重新启动一个人必须简单地接受的东西?
解决方法
Assume that you choose to solve the problem by tracing the root cause of the problem (the memory leaks),how would you collect data to zoom in on the problem?
@H_301_17@使用
jmap
进行堆转储,并使用Eclipse Memory Analyzer加载转储.从那里可以分析哪些对象正在吃掉最多的内存,哪些“根”阻止其他对象被收集等.还有其他堆分析程序,如
jhat
,但我发现EMA是最快最好的(免费)解决方案.Assume that you choose the quick and dirty way of speeding things up by simply restarting the container,how would you collect data to choose the optimal restart cycle?
@H_301_17@使用JMX监视堆大小和其他堆和GC统计信息.
Have you been able to deploy and run projects over an extended period of time without ever restarting the servlet container to regain snappiness?
@H_301_17@是.通过避免/修复内存泄漏.