View gist:cdb961434347056ba66207acfdb4e6c3
Structural Search Template
$ReturnType$ $Method$($ParameterType$ $Parameter$);
Found Matches in JDK (206 usages found)
Library (206 usages found)
Unclassified match (206 usages found)
/home/cchampeau/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/platform/3.4.0/e3f70017be8100d3d6923f50b3d2ee17714e9c13/platform-3.4.0.jar (2 usages found)
com.sun.jna.platform.win32 (2 usages found)
W32Errors (2 usages found)
FAILED(int) (1 usage found)
19public static final boolean FAILED(int hr) {
View quicksort.groovy
import groovy.transform.CompileStatic
@CompileStatic
void swap(int[] a, int i, int j) {
int temp = a[i]
a[i] = a[j]
a[j] = temp
}
@CompileStatic
View Support_for_String_&toUpperCase_method_closures.patch
Index: src/main/org/codehaus/groovy/runtime/MethodClosure.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Local version)
+++ src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Shelved version)
@@ -19,8 +19,8 @@
package org.codehaus.groovy.runtime;
View Support_for_String_&toUpperCase_method_closures.patch
Index: src/main/org/codehaus/groovy/runtime/MethodClosure.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Local version)
+++ src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Shelved version)
@@ -19,8 +19,8 @@
package org.codehaus.groovy.runtime;
View Support_for_String_&toUpperCase_method_closures.patch
Index: src/main/org/codehaus/groovy/runtime/MethodClosure.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Local version)
+++ src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Shelved version)
@@ -19,8 +19,8 @@
package org.codehaus.groovy.runtime;
View how-to-leak.md

If you take a look at the dump here: https://dl.dropboxusercontent.com/u/20288797/temp/memory-dump.tar.bz2

And that you look at the classes, you will see several copies of the classorg.codenarc.rule.Violationororg.codehaus.groovy.antlr.parser.GroovyLexer`. The multiple copies come from different classloaders, which is fine. What is not is that those classes are not retained anymore, nor is their classloader (they are all softly or weakly reachable), but they are not garbage collected, leading to the leak.

To reproduce the PermGen leak, first make sure you use JDK 7 or JDK 6, but the two should be tested independently because Groovy doesn't use the same way to store global class information (ClassValue since JDK 7).

View Rethrow.java
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class Beurk {
private final static Unsafe UNSAFE;
static {
Unsafe unsafe = null;
try {
View build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.11.91.1'
}
}
plugins {
View gitzip.gradle
task srcZip(type:Zip) {
appendix = 'gitsources'
from project.projectDir
doFirst {
Set excludeList = [relativePath(archivePath).toString()]
def p = "git status --ignored --porcelain .".execute([], project.projectDir)
def writer = new StringWriter()
p.consumeProcessOutput(writer, null)
View build.gradle
apply plugin:'java'
repositories {
jcenter()
}
configurations {
manu // une conf qui servira à récupérer la dep sans polluer le classpath de compilation
}