Hi, Regarding #1: I agree with Cedric that WeakReference is a better tool for writing "memory leak" tests. I've done it in the past, having gotten the idea from a Sun blog ([a], which uses the code at [b]).
Regarding #2: It looks like the reify expression actually creates two instances (in Clojure 1.5.1, anyway). There is an initial instance without metadata, then #withMeta is called on that object (adding :column and :line, plus whatever metadata you specify). I saw the extra finalizations go away when I modified the code in your gist to instantiate a deftype'd class instead of using reify. Of course, you don't need to define a type at all if you go with the WeakReference approach. I hope that helps, - Pat [a] https://blogs.oracle.com/xzajo/entry/testing_memory_leaks_with_assertgc [b] http://hg.netbeans.org/main-silver/file/d86d41ca32a4/nbjunit/src/org/netbeans/junit/NbTestCase.java#l1346 On Sunday, July 28, 2013 9:32:59 PM UTC-4, Brandon Bloom wrote: > > Hi all, > > I'm trying to understand the object retention behavior when subseq is > applied to sorted collections. > > A quick glance at the source of > APersistentTreeMap.java<https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentTreeMap.java> > suggests > that the reified subseq only contains pointers to nodes to the left or > right of the initial value node. Assuming I'm reading correctly, that means > subseq should never retain unaccessible nodes in the original sorted map or > set. > > Here's an experiment that seems to back that up: > https://gist.github.com/brandonbloom/6101597 > > This produces a few questions: > > 1. Is my experiment good? > 2. What is the cause of the "double" finalizations? It seems like > every object has an initial speculative finalize fail on it... Why? > 3. Am I correct in saying that subseq will never retain extra objects > from the original tree? > > Thanks, > Brandon > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.