OutOfMemoryError when using the seque function

I have this function that reproduces my problem:

(defn my-problem
  [preprocess count print-freq]
  (doseq [x (preprocess (range 0 count))] 
    (when (= 0 (mod x print-freq)) 
      (println x))))

Everything works fine when I call it using the authentication function as follows:

(my-problem identity 10000000 200000)
;it prints 200000,400000 ... 9800000 just as it should

When I call it with seque , I get an OutOfMemoryError:

(my-problem #(seque 5 %) 10000000 200000)
;it prints numbers up to 2000000 and then it throws OutOfMemoryException

I understand that the seque function should simply split the processing into two threads using a ConcurrentBlockingQueue with a maximum size of 5 (in this case). I do not understand where the memory leak occurs.

+4
source share
1 answer

seque , , , , seque ( ). , , , . , (dorun (seque (range))).

sequeue flatland/useful, , clojure.core. , , .

+5

Source: https://habr.com/ru/post/1529603/


All Articles