Thanks for all the interesting answers.
On Jun 25, 5:23 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote: > On Jun 25, 6:25 am, RichClaxton<rich.clax...@gmail.com> wrote: > > > Hello I have just started learning Clojure and functional programming, > > quick question, what happens internally when I do a defn, does this > > create the byte code, or a ref to the function which is stored, as it > > does actually create a function object, I was just wondering about > > memory and GC issues. > > It gets complicated, because the JVM stores bytecode in a special > memory location that is separate from the heap. In all but very early > versions of Clojure, however, there's a dynamic classloader so that > defined functions can get garbage collected. > > Each (fn ...) or (defn ...) form is a dynamically-created class. But, > as others have said, there is only one class for each time you *write* > (fn...), not a new class each time you call it. So if you have one > (fn...) form that gets called a hundred times with different closed- > over values, it's still only going to create one class. > > The only time GC of fns might be an issue is if you're constructing > the (fn...) forms in code and eval'ing them. Even then, adjusting the > JVM memory parameters should be sufficient. > > -SS --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---