4 ms·
"Lambdas are not garbage collected. Yes. That means lambdas can be the cause of memory leaks. As described by Charles Nutter, each lambda in Clojure is an ano
by tlrobinson 18y ago
"Lambdas are not garbage collected.
Yes. That means lambdas can be the cause of memory leaks.
As described by Charles Nutter, each lambda in Clojure is an anonymous class in Java. The problem is that classes are never garbage collected. They reside in a special place called the PermGen."
I know very little about Clojure, but that seems like a huge problem for Clojure, and other functional-ish JVM languages. Is it?
I've used Rhino (JavaScript on JVM) extensively, and I don't think it suffers from this.
- icey 18y ago"As of r1232, lambdas created in eval can be GCed." - Comment from cgrand at the bottom of the article.
- jstraszheim 18y agoHe means the compiled code of a lambda can't be GC'ed. He was creating new functions inside of an eval. The individual closures created as code executes are GC'ed like everything else. Since eval is rather specialized, and everyone recommends it be avoided in "normal" code, this is not a major problem. Plus, it is fixed.
- GeoJawDguJin 18y agoHonestly, the JVM is pretty crappy right now for functional language support. A lot of stuff has to be implemented by hand in either the compiler or the program itself. Several features in Clojure take the latter track at the moment. I advocate tracking down people from Sun and asking them in a personable, friendly tone of voice to please fix this kind of problem. On their front lawns.