I've worked around this sort of thing in the past by wrapping the
initialization in a closure. My macros:
(defmacro once-fn "Define a function that should only be called once.
Releases local storage earlier"
[args & body]
`(^{:once true} fn* ~args ~...@body))
(defmacro top-level-run "work around a memory leak in the repl"
[& body]
`((once-fn []
~...@body)))
You'll find that:
(def out_of_mem (top-level-run (reduce + 0 (range 500000000))))
does not run out of memory.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en