4 ms·
In this thread: http://markmail.org/message/axarlob7wwmnm2xe#query:clojure%20permgen+page:1+mid:axarlob7wwmnm2xe+state:results http://markmail.org/message/axar
by dreish 18y ago
In this thread:
http://markmail.org/message/axarlob7wwmnm2xe#query:clojure%20permgen+page:1+mid:axarlob7wwmnm2xe+state:results http://markmail.org/message/axarlob7wwmnm2xe#query:clojure%2...
Rich Hickey claims that the PermGen issue alleged in this article doesn't actually exist. A new class is created every time a (fn) is compiled, but only a new instance of that class is created each time it is invoked.
The only thing that generates a new class each time it is called is (eval), which as we all remember from reading our PG, is generally regarded as suspect when used in production code. Obviously you can see this effect at the Clojure REPL, however.
- michaelneale 18y agoYes the PermGen issue in general seems a major weakness of the "Sun" VM (now OpenJDK) - although its not an intractable problem - just an irritation. It seems an out dated idea today to have a separate space/special rules for generated code versus the rest of the heap - I think other VMs like JRockit didn't do that and didn't have that issue. Although - I think the class/classloader relationship is in the spec, so to allow easy GC of generated classes you need to have 1 to 1 with classloaders (I hear that all this is going to change anyway to reflect how people really use things).
- Zak 18y agoGenetic programming generally won't appear in production code, though it might be used to generate production code. Using eval seems reasonable in the context of executing code generated by your program. I'd be interested in hearing about alternatives. In response to this problem, Clojure now uses an ephemeral classloader. I don't know the JVM that well, but Rich Hickey says this means the anonymous classes generated by evaling fn forms can be collected.
- michaelneale 18y agoif all the classes in the classloader are no longer referenced, and there are no references to the classloader itself, then they will all be GCed (but often there is a ref to the classloader that causes the PermGen issue).