This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-25
Channels
- # announcements (9)
- # babashka (38)
- # beginners (41)
- # biff (1)
- # clojure (19)
- # clojure-europe (7)
- # clojure-uk (2)
- # clojurescript (3)
- # code-reviews (30)
- # conjure (4)
- # cursive (8)
- # datomic (32)
- # docker (2)
- # emacs (7)
- # etaoin (2)
- # fulcro (37)
- # graphql (2)
- # jobs (1)
- # jobs-discuss (8)
- # leiningen (10)
- # lsp (36)
- # meander (4)
- # missionary (4)
- # nbb (12)
- # off-topic (1)
- # other-languages (10)
- # pathom (11)
- # re-frame (5)
- # reitit (4)
- # remote-jobs (3)
- # shadow-cljs (13)
- # sql (1)
- # tools-build (4)
- # tools-deps (31)
- # xtdb (2)
(time
(let [n 10000000] ;; 10M
(m/? (m/reduce {}
nil
(m/ap (loop [[x & xs] (range n)]
(if xs
(m/amb> x (recur xs))
(m/amb> x))
))))))
"Elapsed time: 9328.258661 msecs"
9999999
Above code run ok as expected. Higher value of n, e.g. doubling it by 2x will result in OutOfMemoryError. Increasing the JVM memory (e.g. -Xmx2g) will likely just make the OOM error to be thrown longer. More memory will result the jvm hang:
OpenJDK 64-Bit Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGINT to handler- the VM may need to be forcibly terminatedit is a known issue and will be solved in b.27
, this loop can be run in constant space indeed