Skip to content

Instantly share code, notes, and snippets.

@eerohele
Last active March 4, 2016 17:14
Show Gist options
  • Save eerohele/4fd2831db93d4ff072a7 to your computer and use it in GitHub Desktop.
Save eerohele/4fd2831db93d4ff072a7 to your computer and use it in GitHub Desktop.
Gradle DefaultIsolatedAntBuilder PermGen Leak
// Enable the Gradle daemon and run this until failure:
// while gradle --rerun-tasks; do :; done
import org.gradle.api.internal.ClassPathRegistry
import org.gradle.api.internal.DefaultClassPathProvider
import org.gradle.api.internal.DefaultClassPathRegistry
import org.gradle.api.internal.classpath.DefaultModuleRegistry
import org.gradle.api.internal.classpath.ModuleRegistry
import org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder
import org.gradle.internal.classloader.DefaultClassLoaderFactory
ModuleRegistry moduleRegistry = new DefaultModuleRegistry()
ClassPathRegistry registry = new DefaultClassPathRegistry(new DefaultClassPathProvider(moduleRegistry))
DefaultIsolatedAntBuilder antBuilder = new DefaultIsolatedAntBuilder(registry, new DefaultClassLoaderFactory())
defaultTasks 'test'
antBuilder.execute {
// Can be any JAR file
antProject.getClass().classLoader.addURL(new File('/opt/dita-ot/lib/xml-resolver-1.2.jar').toURL())
}
task test {
antBuilder.execute {
echo('hello world')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment