spring-boot - 弹簧启动执行器 InMemoryAuditEventRepository 的内存泄漏
问题描述
我在我的 spring-boot 应用程序中面临内存泄漏,并且在使用 Eclipse MAT 进行 heapdump 分析后,它指出了 spring boot 执行器中的潜在内存:精确地使用 InMemoryAuditEventRepository(审计事件)。
One instance of "org.springframework.boot.actuate.audit.InMemoryAuditEventRepository" loaded by "sun.misc.Launcher$AppClassLoader @ 0xe7020a30" occupies 210 676 784 (57,25%) bytes. The memory is accumulated in one instance of "org.springframework.boot.actuate.audit.AuditEvent[]" loaded by "sun.misc.Launcher$AppClassLoader @ 0xe7020a30".
Keywords
org.springframework.boot.actuate.audit.InMemoryAuditEventRepository
org.springframework.boot.actuate.audit.AuditEvent[]
sun.misc.Launcher$AppClassLoader @ 0xe7020a30
禁用此内存审计事件的最佳方法是什么:
- 删除 spring-boot-actor 依赖
- management.endpoints.enabled-by-default=true
- endpoints.auditevents.enabled=false
提前致谢
解决方案
遇到了同样的发现......
经过一番调查,发现这不是泄漏,而是 Spring Boot 存储了最后 4000 个安全(登录)审计事件。它会增长到那个数字,然后保持在那里......
您可以创建自己的实现,然后将其写入缓存或数据库,而不是将其保存在内存中。
(参考)
推荐阅读
- mongodb - MongoDB Compass - 文档不显示来自另一个集合的对象 ID 引用(Ref)的字段
- javascript - 来自firebase的图像的html2canvas jsPdf访问错误
- javascript - Javascript:如何删除嵌入式删除按钮的父列表项
- java - 如何在 Java 中从用户那里获取多行输入,然后将输入存储在字符串类型的数组中,其中每一行都是数组的一个元素
- sql - 在这个 SQL 作业中遇到一些问题
- php - 无法将获取的行项目保存到会话中
- javascript - 更新 !!Angular 10:向特定模块注入服务,检测到循环依赖。@inject 和提供者[]之间的区别?
- c# - 使用 IEnumerable 或特定类型返回
- php - 表中15条记录的最后一次查询,但包含相关表中的数据
- azure - 无法从 Azure 函数连接到 Azure SQL