Spring启动测试-内存不足问题
我正在尝试使用 Maven 运行测试。应用程序包含junit测试和集成测试。使用以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<junitArtifactName>junit:junit</junitArtifactName>
<encoding>${project.build.sourceEncoding}</encoding>
<argLine>
-Xverify:none
-XX:TieredStopAtLevel=1
-Xms512m -Xmx768m -XX:MaxMetaspaceSize=256m -ea
-XX:MaxRAM=1000m
-Dfile.encoding=${project.build.sourceEncoding}
-Dspring.test.context.cache.maxSize=1
</argLine>
<excludedGroups>${env.MVN_EXCLUDED_TESTS}</excludedGroups>
</configuration>
</plugin>
测试在几乎所有情况下都使用通用配置和一个测试配置文件(对我来说没有什么可疑的)。
我尝试通过设置 maxSize 属性将缓存上下文的数量降低到 1。这可行,但对 OOM 问题没有影响。所以我已经捕获了堆转储,但我不知道那里发生了什么。我可以看到 35 个 org.springframework.beans.factory.support.DefaultListableBeanFactory 实例和 34 个 org.hibernate.internal.SessionFactoryImpl 实例,它们占用了大量内存(见图)。
我只找到了一些关于 DefaultListableBeanFactory 此处 但我怀疑这就是问题所在。
您是否知道要检查或修改哪些内容以降低内存使用量?或者真的有内存泄漏吗?谢谢
I am trying to run tests using maven. Application contains junit tests & integration tests. Following configuration is used:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<junitArtifactName>junit:junit</junitArtifactName>
<encoding>${project.build.sourceEncoding}</encoding>
<argLine>
-Xverify:none
-XX:TieredStopAtLevel=1
-Xms512m -Xmx768m -XX:MaxMetaspaceSize=256m -ea
-XX:MaxRAM=1000m
-Dfile.encoding=${project.build.sourceEncoding}
-Dspring.test.context.cache.maxSize=1
</argLine>
<excludedGroups>${env.MVN_EXCLUDED_TESTS}</excludedGroups>
</configuration>
</plugin>
Tests uses common configuration in nearly all cases with one test profile (nothing is suspicious to me).
I have tried to lower number of cached contexts to 1 by setting maxSize property. That works, but without effect on OOM issue. So I have captured heapdump, but I have no idea whats going on there. I can see 35 instances of org.springframework.beans.factory.support.DefaultListableBeanFactory
and 34 instances of org.hibernate.internal.SessionFactoryImpl
which takes lots of memory (see picture).
I have only find something about DefaultListableBeanFactory here but I doubt that thats the problem.
Do you have any ideas what to check or modify to lower memory usage? Or is there realy any memory leak? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论