[英]Java 8 with Jetty on linux memory issue
Can you please help me resolving the following issue: 你能帮我解决一下这个问题:
Context: 语境:
We are trying to migrate our existing application which is currently running on Java6( on Glassfish) in production to Java8 (on Jetty9) setup. 我们正在尝试将当前在生产中使用Java6(在Glassfish上)运行的现有应用程序迁移到Java8(在Jetty9上)设置。 Earlier, We were able to successfully migrate the same setup on Java7(on jetty9).
早些时候,我们能够在Java7上成功迁移相同的设置(在jetty9上)。 But the customer has decided to go with Java 8 now.
但是客户现在决定使用Java 8。 In this process we have encountered some memory issues and below are the details:
在这个过程中,我们遇到了一些内存问题,下面是详细信息:
Problem Description: 问题描述:
After starting the Jetty server, initial (RES)memory usage of java process is around 5.5g. 启动Jetty服务器后,java进程的初始(RES)内存使用量约为5.5g。 After running the application for sometime the memory usage slowly shoots-up and consumes maximum available physical memory(8g) on the machine, eventually crashing the server/system.
在运行应用程序一段时间之后,内存使用会慢慢启动并消耗机器上最大可用物理内存(8g),最终导致服务器/系统崩溃。
This issue is encountered only on the linux environment. 仅在Linux环境中遇到此问题。 No such issues are found on Windows environment.
在Windows环境中找不到此类问题。
Profiler findings: Profiler调查结果:
Monitored the server with VisualVM and jconsole . 使用VisualVM和jconsole监视服务器。 In both the profilers JVM's memory(heap & non-heap) usage is under the allocated limits.
在两个分析器中,JVM的内存(堆和非堆)使用率都在分配的限制之下。
Environment details: 环境细节:
Java Version : 8
Server : Jetty 9.2.10
OS : linux on a virtual machine(Linux version 2.6.32-279.14.1.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Tue Nov 6 23:43:09 UTC 2012
Java Options :
-Xms3072M
-server
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:+UseG1GC
-XX:MaxGCPauseMillis=75
-Xmx3072M
-Xss1024K
-XX:InitialCodeCacheSize=192M
-XX:CodeCacheExpansionSize=3M
-XX:CodeCacheMinimumFreeSpace=3M
-XX:ReservedCodeCacheSize=600M
-XX:MinMetaspaceExpansion=3M
-XX:MaxMetaspaceExpansion=18M
-XX:MaxMetaspaceSize=500M
-XX:MaxDirectMemorySize=288M
-XX:CompressedClassSpaceSize=512M
-XX:ParallelGCThreads=12
-XX:ConcGCThreads=4
-Dsun.rmi.dgc.server.gcInterval=86400000
-Dsun.rmi.dgc.client.gcInterval=86400000
PS: Please don't mark this as duplicate. PS:请不要将此标记为重复。 I have read many answers on stackoverflow, but nothing addressed or solved my issue.
我已经在stackoverflow上阅读了很多答案,但没有解决或解决我的问题。
Update 更新
I started jetty with the following Java Options, and since then the memory usage is between 4.5g-4.8g (approximately 142 hours). 我使用以下Java选项启动了jetty,从那时起内存使用量介于4.5g-4.8g(大约142小时)之间。 It looks stable to me.
它看起来很稳定。 I reserved around 2g of memory through java option flags(Xmx & MetaspaceSize), but additional 2.5g is used always.
我通过java选项标志(Xmx和MetaspaceSize)保留了大约2g内存,但总是使用额外的2.5g内存。 Is this normal behavior for Java 8 on a linux machine?
这是Linux机器上Java 8的正常行为吗?
Java Options used: 使用的Java选项:
-server
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../logs/jvm.log
-XX:+UseG1GC
-XX:MaxGCPauseMillis=75
-XX:ParallelGCThreads=12
-XX:ConcGCThreads=12
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-Xloggc:../logs/gc.log
-XX:NativeMemoryTracking=summary
-Xmx1500m
-Xss256k
-XX:MaxMetaspaceSize=512m
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/opt/logs/jetty.hprof
-Dsun.rmi.dgc.server.gcInterval=86400000
-Dsun.rmi.dgc.client.gcInterval=86400000
Thanks for your time! 谢谢你的时间!
It seems to be an issue in Java8/9 that manifests itself in Jetty due to the annotations module that scans the jars and has a memory leak. 它似乎是Java8 / 9中的一个问题,由于注释模块扫描jar并且存在内存泄漏,因此它在Jetty中表现出来。 Ref.
参考。 https://github.com/eclipse/jetty.project/issues/575 .
https://github.com/eclipse/jetty.project/issues/575 。 A solution for me (because I do not use Jetty annotations) is to disable the annotations module by commenting out the lines in jetty/modules/annotations.mod.
我的解决方案(因为我不使用Jetty注释)是通过注释掉jetty / modules / annotations.mod中的行来禁用注释模块。 So tie file looks like this:
所以tie文件看起来像这样:
#
# Jetty Annotation Scanning Module
#
[depend]
# Annotations needs plus, and jndi features
plus
[lib]
# Annotations needs jetty annotation jars
lib/jetty-annotations-${jetty.version}.jar
# Need annotation processing jars too
#lib/annotations/*.jar
[xml]
# Enable annotation scanning webapp configurations
#etc/jetty-annotations.xml
Edit 1 - Alternative solution 编辑1 - 替代解决方案
Switching off all annotation scanning can be too drastic, it turns of jsp as well because it is dependent. 关闭所有注释扫描可能过于激烈,它也会转变为jsp,因为它是依赖的。 The alternative is to provide a web application context which restricts the scanning using a pattern.
替代方案是提供使用模式限制扫描的Web应用程序上下文。 Save this in an xml and deploy it in the webapps together with the war or include it in the war.
将其保存在xml中,并将其与战争一起部署在webapps中,或将其包含在战争中。
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/[myApp]</Set>
<Set name="war">/[DIRECTORY]/[myApp[.war</Set>
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>SCAN-NO-JARS</Arg>
</Call>
</Configure>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.