首页 > 解决方案 > 堆大小迅速增加弹簧启动应用程序

问题描述

我在spring boot上有应用程序,使用mongoDB和hibernate for MySQL。应用程序的堆大小在生产中不断增加。我提供的最大堆大小为 24 GB,这已经很大了。现在使用的堆达到 23 GB。对如此巨大的内存进行堆转储是否很好,它会影响性能,因为它是实时应用程序。

另一种检测内存泄漏的方法?或者其他分析休眠或mongo指标的方法?

标签: javamongodbhibernatespring-bootjvm

解决方案


Try to see the heap memory in jprofiler or jvisualvm. One of the options could be that heap would take all the memory you provide, but use only some part of it. In general it would depend of Garbage Collector algorithm. I would recommend you to perform following steps:

1) Check if the memory taken by heap is actually used (you can see it in jprofiler or jvisualvm). If the application is taking all memory but doesn't use it you can restrict it with some reasonable value using Xmx jvm argument.

2) See the memory usage under the load and idle. See the difference. Depending on the operations you do there might be some objects sitting in memory, but they should be collected time-to time.

3) If it is really leak and you see the memory reserved by jvm is really used and never released - take a memory dump and see what kind of objects are sitting there (again try jprofiler or jvisualvm). This will give you a clue where to look.


推荐阅读