clojure - Out of memory on spit -
i don't understand why code raise out of memory exception.
i have agent call function append line "test.log" file. out of memory on persistenthashmap $ bitmapindexednode.assoc(persistenthashmap.java:624)
.
(use 'clojure.java.io) (def the-agent(agent nil)) (defn process [_o content] (spit "test.log" content :append true) ) (defn write-all [] (doseq [x (range 1 5000000)] (send-off the-agent process "line appended\n" ) ) )
thanks !
the dispatched sends blocked on i/o on individual spits. dispatches created faster can completed , accumulating.
(defn write-all [] (doseq [x (range 1 5000000)] (send-off the-agent process "foo") (when (zero? (mod x 100000)) (println (. the-agent clojure.lang.agent/getqueuecount))))) user=> (write-all) 99577 199161 298644 398145 497576 596548 exception in thread "nrepl-worker-0" java.lang.outofmemoryerror: java heap space
Comments
Post a Comment