memory - When should I avoid using `seq` in Clojure? -



memory - When should I avoid using `seq` in Clojure? -

in this thread, learned keeping reference seq on big collection prevent entire collection beingness garbage-collected.

first, thread 2009. still true in "modern" clojure (v1.4.0 or v1.5.0)?

second, issue apply lazy sequences? example, (def s (drop 999 (seq (range 1000)))) allow garbage collector retire first 999 elements of sequence?

lastly, there way around issue big collections? in other words, if had vector of, say, 10 1000000 elements, consume vector in such way consumed parts garbage collected? if had hashmap 10 1000000 elements?

the reason inquire i'm operating on big info sets, , having more careful not retain references objects, objects don't need can garbage collected. is, i'm encountering java.lang.outofmemoryerror: gc overhead limit exceeded error in cases.

it case if "hold onto head" of sequence clojure forced maintain in memory. doesn't have choice: still keeping reference it.

however "gc overhead limit reached" isn't same out of memory error - it's more sign running fictitious workload creating , discarding objects fast tricking gc thinking overloaded.

see:

gc overhead limit exceeded

if set actual workload on items beingness processed, suspect see error won't happen more. can process lazy sequences larger available memory in case.

concrete collections vectors , hashmaps different matter however: these not lazy, must held in memory. if have datasets larger memory options include:

use lazy sequences , don't hold onto head use specialised collections back upwards lazy loading (datomic uses structures believe) treat info event stream (using storm) write custom code partition info chunks , process them 1 @ time.

memory memory-management clojure garbage-collection

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -