From 801116c2d5830e81242d9ff6edef9d1fa21b8d50 Mon Sep 17 00:00:00 2001 From: Jonas Scherbaum Date: Mon, 15 Jul 2019 11:16:42 +0200 Subject: [PATCH] Fixed the Reference of the metaclass in ClassInfo.java to use a WeakReference now, so the Reference is cleaned up nearly immediately after freeing the last strong reference of the metaclass. Prior it was used a SoftReference which prevents the ClassLoader, the ClassInfo and the Metaclass instances from beeing garbage-collected until the JVM runs nearly into an OutOfMemoryException (PermGen). This leads to a JVM which is always near the maximum of memory usage. --- src/main/java/org/codehaus/groovy/reflection/ClassInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java b/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java index 2c4ae9a0040..60ba70e58b2 100644 --- a/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java +++ b/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java @@ -244,7 +244,7 @@ public void setWeakMetaClass(MetaClass answer) { strongMetaClass = null; ManagedReference newRef = null; if (answer != null) { - newRef = new ManagedReference (softBundle,answer); + newRef = new ManagedReference (weakBundle,answer); } replaceWeakMetaClassRef(newRef); }