Skip to content

Instantly share code, notes, and snippets.

@shenie
shenie / memory-leak.groovy
Last active January 3, 2016 07:39
Memory leak in groovy with toString() on instances of mixed in class
class BarMixin {
}
Date.mixin(BarMixin)
100.times {
println "#${it + 1}"
def bar = new Date()
bar.toString()
sleep 100
public String convertToString(GPathResult doc) {
def defaultNamespace = doc.lookupNamespace('')
if (defaultNamespace) {
def docWithNamespace = {
mkp.declareNamespace("": defaultNamespace)
out << doc
}
return new StreamingMarkupBuilder().bind(docWithNamespace)
} else {