That did it! I just used the functions that created my-row-data in place of my-row-data. Thanks very much for the help. PJ
On Apr 2, 1:34 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > Difficult without seeing the code. > > the idea is to try not storing what is currently in my-row-data anywhere. > > So if you can create a function that returns what is currently stored in > my-row-data, and pass that function to your function t, then the head of > your sequence will not be retained in any variable, so it can be garbage > collected while doseq is still working on the rest of the sequence. > > Your code could be changed as : > > (defn t [filename my-row-data-fn] > (with-open [w (java.io.FileWriter. (java.io.File. file-name))] > (doseq [l (my-row-data-fn)] > (.write w (str (output-array (first l) ",") > "@" > > (output-array (second l) ",") > > "\n"))))) > > Hope this helps, if not, you will have to show us more code above the t > function, > > -- > Laurent > > 2009/4/2 fitzpatrick...@googlemail.com <fitzpatrick...@googlemail.com> > > > > > Apologies for my ignorance ,i am new to clojure, but can you give an > > example of what the code should look like. I understand my-row-data is > > lexical as it defined outside the function but i don't understand how > > to implement this new function. > > tks, > > PJ > > > On Apr 2, 1:03 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > > > You're holding the head, because my-row-data is defined in the lexical or > > > dynamic scope of the function, and holds the head. > > > > Try creating a function returning the seq that is currently stored in > > > my-row-data and call it instead : (my-row-data) > > > > -- > > > Laurent > > > > 2009/4/2 fitzpatrick...@googlemail.com <fitzpatrick...@googlemail.com> > > > > > Hi, > > > > Thanks for the replies. > > > > > I have adapted the code above with my example. I still get the heap > > > > error! > > > > my-row-data is the lazy sequence. each element in the seq is a 2 > > > > element vector of Java String[] > > > > output-array is just a printing function for the String[]. For > > > > convenience i place a @ between the two outputs. > > > > > (defn t [file-name] > > > > (with-open [w (java.io.FileWriter. (java.io.File. file-name))] > > > > (doseq [l my-row-data] > > > > (.write w (str (output-array (first l) ",") > > > "@" > > > > > (output-array (second l) ",") > > > > > "\n") > > > > > ) > > > > ) > > > > ) > > > > ) > > > > > tks, > > > > PJ > > > > > On Apr 2, 12:15 pm, Christian Vest Hansen <karmazi...@gmail.com> > > > > wrote: > > > > > On Thu, Apr 2, 2009 at 11:58 AM, fitzpatrick...@googlemail.com > > > > > > <fitzpatrick...@googlemail.com> wrote: > > > > > > > Hi, > > > > > > I am attempting to print a large lazy seq to file. I have attempted > > > > > > various approaches and obviously am missing something obvious. > > > > > > I have attempted do use do-seq and also iterated manually through > > the > > > > > > sequence but i always come up with the heap error. > > > > > > Has anyone got any suggestions? > > > > > > Don't hold on to the head of the seq. > > > > > > It may not be obvious where, but you are most likely holding on the > > > > > the head of the seq, which prevents the elements from being GC'd as > > > > > you iterate them. > > > > > > > tks, > > > > > > PJ > > > > > > -- > > > > > Venlig hilsen / Kind regards, > > > > > Christian Vest Hansen. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---