Nice!  I hadn't seen that before.

Thank you both.


On Sat, Mar 29, 2014 at 3:29 PM, Jonas <jonas.enl...@gmail.com> wrote:

> You could give core.rrb-vector[1]. From the docs:
>
>     The main API entry points are clojure.core.rrb-vector/catvec,
> performing vector concatenation, and clojure.core.rrb-vector/subvec, which
> produces a new vector containing the appropriate subrange of the input
> vector (in contrast to clojure.core/subvec, which returns a view on the
> input vector).
>
> [1] https://github.com/clojure/core.rrb-vector
>
>
> On Saturday, March 29, 2014 8:42:25 PM UTC+2, Ryan Waters wrote:
>
>> If you do a (count @mem) it reports the length of the atom's vector isn't
>> growing without bounds.  It seems counterintuitive that the parts of the
>> old vector wouldn't get garbage collected because the atom no longer points
>> to them.  But I guess I need to rtfd.
>>
>> Thank you.
>>
>>
>> On Sat, Mar 29, 2014 at 10:07 AM, Aaron Cohen <aa...@assonance.org>wrote:
>>
>>>
>>>
>>> On Sat, Mar 29, 2014 at 10:09 AM, Ryan Waters <ryan....@gmail.com>wrote:
>>>
>>>> I have some code that blows up the heap and I'm not sure why.  I've
>>>> reduced it down to the following.
>>>>
>>>> I've tried to make sure the atom doesn't have boundless growth and I
>>>> didn't think 'while' hangs on to the head of sequences so I'm embarrassed
>>>> to say I'm stumped.
>>>>
>>>>
>>>> (defn leaks-memory
>>>>   []
>>>>   (let [mem (atom [])
>>>>         chunksize 1000
>>>>         threshold 2000]
>>>>   (while true
>>>>     (swap! mem conj (rand-int 100))
>>>>
>>>>     ; every 'chunksize' item past 'threshold'
>>>>     (when (and (= 0 (mod (count @mem) chunksize))
>>>>                (> (count @mem) threshold))
>>>>       (swap! mem subvec chunksize)))))
>>>>
>>>> (doc subvec)
>>>
>>> Returns a persistent vector of the items in vector from
>>> start (inclusive) to end (exclusive). If end is not supplied,
>>> defaults to (count vector). This operation is O(1) and very fast, as
>>> the resulting vector shares structure with the original and no
>>> trimming is done.
>>>
>>> subvec is fast, but it's not saving you any memory.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to