Dear all, I really love programming in Clojure, and have done so for the past couple of months, building my company's software recommendation engine in Clojure (not in production yet), which I originally wrote in Ruby. However I have run into the following a memory problem, which actually was pointed out by Christophe Grand in a response on stackoverflow (http://stackoverflow.com/questions/749911/how-can-i-leak-memory-in- clojure).
In my case I want to calculate (usage) correlations between items, and pick for each item its most similar items. For example, If I compare one item with 1.000.000 others, and calculate their similarities, then next I sort the collection, and pick only the top (say 10) Artificial code example: (take 10 (sort (for [x (range 1000000)] (rand))))) Now the problem is the memory usage, as it does not merely uses memory space for 10 items, but it keeps a reference to the entire sequence. If I leave out the sort its all ok, and done lazily. Does anyone know how to sort and avoid large memory consumptions? Thanks in advance. (I'm running on Mac OSX with Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---