简体   繁体   English

内存提升后java.lang.ref.Finalizer OutOfMemory

[英]java.lang.ref.Finalizer OutOfMemory After Memory Raise

Extracting a heapdump I realized it has a lot of objects waiting finalization, most of them are instances from libraries like jdbc connections and so on. 提取一个heapdump时,我意识到它有很多等待完成的对象,其中大多数是来自jdbc连接等库的实例。

Knowing that those instances on the queue are basically classes that implements finalize() , why would they simply not be finalized? 知道队列中的那些实例基本上是实现finalize() ,为什么不将它们简单地终结?

A few days ago I raised the memory of such instance. 几天前,我提起了这种情况的记忆。 Initially it had 1GB with new generation set to 256 MB ( -Xmx1g -XX:NewSize=256m -XX:MaxNewSize=256m ). 最初它有1GB,新一代设置为256 MB( -Xmx1g -XX:NewSize=256m -XX:MaxNewSize=256m )。 As we added some heavy caching functionalities we raised the memory assigned to that instance to 3 GB ( -Xmx3G -XX:NewSize=512m -XX:MaxNewSize=512m ). 添加一些繁重的缓存功能后,我们将分配给该实例的内存提高到3 GB( -Xmx3G -XX:NewSize=512m -XX:MaxNewSize=512m )。 From that moment we start to see some out of memories. 从那一刻起,我们开始看到一些回忆。 Investigating it a bit I found out a lot of java.lang.ref.Finalizer and objects waiting for finalization. 经过一些调查,我发现了很多java.lang.ref.Finalizer和等待完成的对象。

How could this be related to each other? 这如何相互联系? May it be even related? 可能甚至相关吗?

why would they simply not be finalized? 为什么根本不将其最终确定?

Some components take longer to finalize esp anything which involves IO. 一些组件花费更长的时间才能完成esp涉及IO的所有操作。 JDBC connections are relatively heavy weight network resources so they take even longer. JDBC连接是相对较重的网络资源,因此花费的时间更长。

I suggest you use a connection pool (most JDBC libraries have them built in) This way you are not creating/destroying them all the time. 我建议您使用连接池(大多数JDBC库都内置了连接池),这样就不会一直在创建/销毁它们。

Note: to clarify 1Gb = 1 gig-bit or 128 MB (Mega-bytes) 256 mb is 256 milli-bits or about 1/4 of a bit. 注意:要澄清1Gb = 1个1Gb位或128 MB(兆字节), 256 mb是256毫比特或大约1/4比特。 -XX:NewSize=512m is 512 MB not 256 MB. -XX:NewSize=512m是512 MB而不是256 MB。 and -XX:MaxNewSize=512 wouldn't work as it is just 512 bytes, most likely you used -XX:MaxNewSize=512m -XX:MaxNewSize=512无效,因为它只有512个字节,很可能是您使用的-XX:MaxNewSize=512m

3Gb is 3 giga-bits but assuming you meant 3 GB it is not -Xmx1G which is 1 GB or 8 Gb. 3Gb是3 GB,但假设您要表示3 GB,则不是-Xmx1G ,而是1 GB或8 Gb。

Object.finalize() is called by the garbage collector on final step of the cleanup. 垃圾收集器在清理的最后一步调用Object.finalize() The GC runs periodically (depending on which GC you are using, if 7 and 8 it's probably CMS, or G1 if you so configured). GC定期运行(取决于您使用的是哪个GC,如果是7和8,则可能是CMS,或者如果配置了G1,则为G1 )。 Having a lot of objects in 'waiting finalization' may mean that you have a large heap and enough memory that the GC did not need to run (CMS most likely, as G1 runs micro cleanups a lot more frequently). 在“等待完成”中有很多对象可能意味着您有一个大堆,并且有足够的内存使GC不需要运行(CMS很有可能,因为G1运行微清理的频率更高)。

Add GC tracing to your JVM startup parameters and monitor how often it runs: -XX:+PrintGCDetails -XX:+PrintGCTimeStamps See: http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html 将GC跟踪添加到JVM启动参数,并监视其运行频率:-XX:+ PrintGCDetails -XX:+ PrintGCTimeStamps请参见: http : //www.oracle.com/technetwork/java/javase/gc-tuning-6-140523 html的

If you are using lots of small objects with a heap >1Gb you may want to consider using the G1 garbage collector as it is better suited for such a task and doesn't have the 'stop the world' behavior of CMS. 如果您正在使用堆大于1Gb的许多小对象,则可能要考虑使用G1垃圾收集器,因为它更适合此类任务,并且不具有CMS的“世界停止”行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java Memory 问题:Java.lang.ref.finalizer object - Java Memory issue : Java.lang.ref.finalizer object Wildfly 10.1.0.FINAL(java.lang.ref.Finalizer / ActiveMQConnection)上的内存泄漏 - Memory leak on Wildfly 10.1.0.FINAL (java.lang.ref.Finalizer / ActiveMQConnection) 使用 Spring webServiceTemplate 和 jaxb 库会导致 «java.lang.ref.Finalizer» 的内存泄漏 - Using Spring webServiceTemplate and jaxb library leads to memory leak with «java.lang.ref.Finalizer» 是内存泄漏吗? 为什么 java.lang.ref.Finalizer 吃掉这么多内存 - is memory leak? why java.lang.ref.Finalizer eat so much memory Java 在 java.lang.ref.Finalizer 上设置的断点未停止 - Java Breakpoint set on java.lang.ref.Finalizer not stopped Finalizer线程正在等待时java.util.ref.Finalizer的内存泄漏 - Memory leak of java.util.ref.Finalizer while Finalizer thread is waiting Memory 语义 java.lang.ref.Reference 方法 - Memory semantics of java.lang.ref.Reference methods 由java.lang.ref.FinalizerReference引起的内存泄漏 - Memory leak caused by java.lang.ref.FinalizerReference Java内存泄漏终结器工具包 - Java Memory Leaks Finalizer Your Kit 高 XMX:java.lang.outofmemory 本机内存分配 (malloc) 未能为 ChunkPool::allocate 分配 32756 字节 - High XMX: java.lang.outofmemory native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM