WebSphere 7 - 过多的垃圾收集会导致内存不足吗?

时间:2021-01-04 20:58:21

Issue: Getting out of native memory exception and was wondering if excessive garbage collection can lead to this? Also any advice on GC policy or tuning would be helpful. I'm not sure if what I have warrants a change yet.

问题:摆脱本机内存异常,并想知道过多的垃圾收集是否会导致这种情况?关于GC政策或调整的任何建议都会有所帮助。我不确定我还有什么保证会改变。

Good Reference * Question: Which GC Policy to Use

好参考*问题:使用哪个GC策略

Specs:

  • Server Environment: Websphere Version 7
  • 服务器环境:Websphere版本7

  • GC Policy : Default ( optthruput )
  • GC策略:默认(optthruput)

  • Java 1.5
  • Heap: 8 GB
  • 堆:8 GB

  • Running in a VM
  • 在VM中运行

  • Analysis Tool: App Dynamics
  • 分析工具:App Dynamics

Preliminary Analysis:

  1. I assumed memory leak however the garbage collection looks ok as it reclaims memory
  2. 我假设内存泄漏,但垃圾收集看起来没问题,因为它回收内存

  3. Native memory exception makes me think that memory outside of the VM is being exhausted, however i am not sure how.
  4. 本机内存异常使我认为VM外部的内存已经耗尽,但我不知道如何。

Attached Screenshot:

1.1 - 4 hour period of heap utilization . Each little green garbage can represents a major garbage collection point. 1.2 GC time spend in the above graph. 1.3 What the heap utilization looked like during a out of memory exception.

1.1 - 4小时的堆利用期。每个小绿色垃圾都可以代表一个主要的垃圾收集点。 1.2 GC时间花费在上图中。 1.3内存不足异常期间堆利用率的样子。

WebSphere 7  - 过多的垃圾收集会导致内存不足吗?

Exception:

EJB threw an unexpected (non-declared) ejb Exception data: java.lang.OutOfMemoryError: native memory exhausted at garbagecollection.mycode.test at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1658) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1598) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:149) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125) at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:80) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:935) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:503) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:875) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83) at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1646)

EJB抛出了一个意外的(未声明的)ejb异常数据:java.lang.OutOfMemoryError:在com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1658)的garbagecollection.mycode.test中用尽的本机内存com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1598)位于com.ibm.ws.webcontainer的com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:149)。 filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125)at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper。 java:190)at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125)at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)at com.ibm .ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125)at com.ibm.ws.webcontainer.filter.WebAppF ilterChain._doFilter(WebAppFilterChain.java:80)位于com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)的com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java: 935)com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:503)at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)at com.ibm.ws位于com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:875)的com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java)中的.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91) :1592)com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)at at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)at com.ibm.ws.http.channel.inbound.impl.HttpIn在com.ibm.ws.ssl.channel.impl.SSLReadServiceContext $的com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)上的boundLink.processRequest(HttpInboundLink.java:306) SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java: 217)位于com.ibm.io.async.ResultHandler的com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) .complete(ResultHandler.java:204)com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)com的com.ibm.io.async.ResultHandler $ 2.run(ResultHandler.java:905) .ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1646)

1 个解决方案

#1


The error message you get indicate a problem with native memory, that is, memory outside the heap. The garbage collector is not responsible for off-the-heap memory, why you can not affect this error with garbage collector settings. Excessive garbage collecting should not lead to native memory issues (unless there is a bug in the GC, of course).

您收到的错误消息表明本机内存存在问题,即堆外部的内存。垃圾收集器不负责堆外存储器,为什么不能使用垃圾收集器设置来影响此错误。过多的垃圾收集不应导致本机内存问题(当然,除非GC中存在错误)。

What is causing this particular error is hard to say without more information. I assume you have at least 12 GB of available RAM on the machine? Otherwise you are simply running a heap that is too big for the available memory.

没有更多信息,很难说是造成这种特殊错误的原因。我假设你机器上至少有12 GB的可用内存?否则,您只是运行一个对可用内存来说太大的堆。

Some examples of things in Java that can exhaust native memory:

Java中可能耗尽本机内存的一些例子:

  • Leaks in native (JNI) code

    本机(JNI)代码泄漏

  • Direct allocation of many ByteBuffers

    直接分配许多ByteBuffers

Or maybe there is no leak, this behavior is expected for your application, and you only need to allow larger processes or buy some more memory.

或者也许没有泄漏,这种行为是您的应用程序所期望的,您只需要允许更大的进程或购买更多的内存。

First step to troublehsoot would be to check the process size against possible process size limits. You could simply run into such a limit without there being an actual leak.

麻烦的第一步是检查过程大小与可能的过程大小限制。如果没有实际的泄漏,你可以简单地遇到这样的限制。

If that is not the problem, track the process size over time, especially in relation to available memory to see if you have a "leaky" behavior.

如果这不是问题,请跟踪进程大小,特别是与可用内存有关,以查看是否存在“泄漏”行为。

If you actually think you have a native memory leak, identify which libraries that use JNI you are using (e.g. JDBC drivers) and try to replace them with Java-only versions. Also, check for known memory leak bugs in such libraries and your JVM version and WebSphere version.

如果您确实认为自己有本机内存泄漏,请确定使用您正在使用的JNI的库(例如JDBC驱动程序)并尝试将它们替换为仅Java版本。此外,检查此类库中的已知内存泄漏错误以及JVM版本和WebSphere版本。

If that fails you will have to resort to native memory leak troubleshooting tools. That is another question.

如果失败,您将不得不求助于本机内存泄漏故障排除工具。那是另一个问题。

#1


The error message you get indicate a problem with native memory, that is, memory outside the heap. The garbage collector is not responsible for off-the-heap memory, why you can not affect this error with garbage collector settings. Excessive garbage collecting should not lead to native memory issues (unless there is a bug in the GC, of course).

您收到的错误消息表明本机内存存在问题,即堆外部的内存。垃圾收集器不负责堆外存储器,为什么不能使用垃圾收集器设置来影响此错误。过多的垃圾收集不应导致本机内存问题(当然,除非GC中存在错误)。

What is causing this particular error is hard to say without more information. I assume you have at least 12 GB of available RAM on the machine? Otherwise you are simply running a heap that is too big for the available memory.

没有更多信息,很难说是造成这种特殊错误的原因。我假设你机器上至少有12 GB的可用内存?否则,您只是运行一个对可用内存来说太大的堆。

Some examples of things in Java that can exhaust native memory:

Java中可能耗尽本机内存的一些例子:

  • Leaks in native (JNI) code

    本机(JNI)代码泄漏

  • Direct allocation of many ByteBuffers

    直接分配许多ByteBuffers

Or maybe there is no leak, this behavior is expected for your application, and you only need to allow larger processes or buy some more memory.

或者也许没有泄漏,这种行为是您的应用程序所期望的,您只需要允许更大的进程或购买更多的内存。

First step to troublehsoot would be to check the process size against possible process size limits. You could simply run into such a limit without there being an actual leak.

麻烦的第一步是检查过程大小与可能的过程大小限制。如果没有实际的泄漏,你可以简单地遇到这样的限制。

If that is not the problem, track the process size over time, especially in relation to available memory to see if you have a "leaky" behavior.

如果这不是问题,请跟踪进程大小,特别是与可用内存有关,以查看是否存在“泄漏”行为。

If you actually think you have a native memory leak, identify which libraries that use JNI you are using (e.g. JDBC drivers) and try to replace them with Java-only versions. Also, check for known memory leak bugs in such libraries and your JVM version and WebSphere version.

如果您确实认为自己有本机内存泄漏,请确定使用您正在使用的JNI的库(例如JDBC驱动程序)并尝试将它们替换为仅Java版本。此外,检查此类库中的已知内存泄漏错误以及JVM版本和WebSphere版本。

If that fails you will have to resort to native memory leak troubleshooting tools. That is another question.

如果失败,您将不得不求助于本机内存泄漏故障排除工具。那是另一个问题。