rmi中潜在的内存泄漏

时间:2013-10-18 18:48:53

标签: java memory-leaks garbage-collection jvm rmi

我们有一项通过JMX监控的服务。 JVM堆使用量正在增长,甚至主要集合也无法删除垃圾。检查堆显示由RMI相关引用(大多数,如果不是全部,相关的类加载器)组成的垃圾。缓解问题的唯一方法是通过JMX发出显式gc调用(删除所有累积的垃圾)。我们的gc相关选项是:

-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=1
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly

我们没有触及过:DisableExplicitGC或sun.rmi.dgc.server.gcInterval

我认为问题应该由sun.misc.GC.Daemon中的代码解决:

public void run() {
        for (;;) {
            long l;
            synchronized (lock) {

                l = latencyTarget;
                if (l == NO_TARGET) {
                    /* No latency target, so exit */
                    GC.daemon = null;
                    return;
                }

                long d = maxObjectInspectionAge();
                if (d >= l) {
                    /* Do a full collection.  There is a remote possibility
                     * that a full collection will occurr between the time
                     * we sample the inspection age and the time the GC
                     * actually starts, but this is sufficiently unlikely
                     * that it doesn't seem worth the more expensive JVM
                     * interface that would be required.
                     */
                    System.gc();
                    d = 0;
                }

                /* Wait for the latency period to expire,
                 * or for notification that the period has changed
                 */
                try {
                    lock.wait(l - d);
                } catch (InterruptedException x) {
                    continue;
                }
            }
        }
    }

由于某种原因,未调用上述System.gc(已通过查看gc日志进行验证)。有人建议如何解决这个问题吗?

0 个答案:

没有答案