groovy/groovy-core — pull request #501 by candrews (2014-08-09 07:15:50+00:00)
Title: GROOVY-7017: Use a new class loader for each GStringTemplateScript class

I discovered this issue while working on https://jira.grails.org/browse/GRAILS-11296

Each time GStringTemplateEngine compiles a template, it makes a new class. However, it makes all those new classes on the main (parent) class loader. Since that class loader has loaded many other classes that won't ever get GC'ed, and a class can only be GC'ed when it's class loader is GC'ed and vice versa, these GStringTemplateEngine created classes can never be GC'ed. With enough invocations, memory is exhausted. These classes show up in memory dumps as "GStringTemplateScript" followed by a number.