I need to read WAV files, and don't have time to recode the reader in
Clojure. It's Java, and it's got side effects. I can read a number
of frames from the WAV file with this code:
(defn read-frames [wav-file num-frames]
(let [num-samples (* num-frames (.getNumChannels wav-file))
It appears I'm not understanding how something works in the REPL (or
maybe deeper). For instance:
(def big (range 1000))
; memory is small now
(count big) = 1000
; memory is huge now
(System/gc)
; memory is still huge now
(def big nil)
(System/gc)
; memory is small again
So somehow when
Range is lazy.
First you define a range, which is just a promise that the variable will
be rendering a seq with 10M when asked for the elements.
When you count the sequence you realize it and it takes up much space. When
you let go if it it's of course GCed.
The problem is that you hold on to