I have some Clojure code that throws this, occasionally. Unfortunately I
can’t paste my real function here, but it looks much like the one below.
(Changed variable names and simplified some irrelevant - I hope - details).
Anything jump out as a memory-leak?
It queries a DB table to get a list of records. For performance reasons, it
runs multiple smaller queries by time period (min-t, max-t), and furthering
breaks the results into chunks, as it accumulates the final vector
`records`.
I thought each loop/recur would drop the data from the previous loop
iteration. But maybe not?
(defn find-db-records [db min-time max-time]
(let [records (atom [])
num-processed (atom 0)]
(loop [min-t min-time]
(let [max-t (plus-minutes min-t 30) ;; 30 minutes at a time
results (jdbc/query db
["select id, a, b, c from sometable where t > ?
and t <= ? order by t"
min-t max-t])
row-groups (partition-all 200 results)]
(doseq [rows row-groups :let [foo (make-foo rows)]]
(doseq [{:keys [id a b c] :as row} rows]
(if (relevant-record? foo a b)
(let [d (compute-d a b c)]
(swap! records conj {:id id :a a :d d})))
(swap! num-processed inc)))
(if (before? max-t max-time)
(recur max-t)
{:records @records :num-processed @num-processed})))))
--
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.