Forked from timcharper/lazy_seq_head_retention_test.clj
Created
August 6, 2010 14:52
-
-
Save bmabey/511428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns memory-leak | |
(:use [lt.map-pipeline] | |
[clojure.contrib.seq-utils :only [fill-queue]])) | |
(defonce quit? (atom false)) | |
;; Doesn't leak | |
@(future (let [dates (repeatedly (fn [] | |
(java.lang.Thread/sleep 1) | |
(when @quit? (throw (Exception. "quitting!"))) | |
(java.util.Date.)))] | |
(doseq [date dates] date))) | |
;; Does leak | |
(let [dates (repeatedly (fn [] | |
(java.lang.Thread/sleep 1) | |
(when @quit? (throw (Exception. "quitting!"))) | |
(java.util.Date.)))] | |
@(future (doseq [date dates] date))) | |
;; this block of code will quit | |
(do | |
(reset! quit? true) | |
(java.lang.Thread/sleep 1000) | |
(reset! quit? false)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment