<br><br><div class="gmail_quote">On Thu, Jun 9, 2011 at 7:23 PM, Max Bolingbroke <span dir="ltr">&lt;<a href="mailto:batterseapower@hotmail.com">batterseapower@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Dmitri,<br>
<div class="im"><br>
On 9 June 2011 09:13, Dmitri O.Kondratiev &lt;<a href="mailto:dokondr@gmail.com">dokondr@gmail.com</a>&gt; wrote:<br>
&gt; I wonder how Haskell will distribute memory between the buffer for<br>
&gt; sequential element access (list elements, map tree nodes) and memory for<br>
&gt; computation while reading in list, Data.Map from file?<br>
<br>
</div>Your list only has 30,000 elements. From the description of the<br>
problem, you traverse the list several times, so GHC will create an<br>
in-memory link list that persists for the duration of all the<br>
traversals. This is OK, because the number of elements in the list is<br>
small.<br>
<br>
For the construction of the Map, it sounds like in the worst case you<br>
will have 30,000*30,000 = 900,000,000 elements in the Map, which you<br>
may not want to keep in memory. Assuming &quot;show&quot;, &quot;read&quot; and list<br>
creation are lazy enough, and as long as you use the Map linearly GHC<br>
should be able to GC parts of it to keep the working set small. You<br>
should experiment and see what happens.<br>
<br>
My advice is just write the program the simple way (with show and<br>
read, and not worrying about memory) and see what happens. If it turns<br>
out that it uses too much memory you can come back to the list with<br>
your problematic program and ask for advice.<br>
<font color="#888888"><br>
Max<br>
</font></blockquote></div><br><br clear="all">Yes, that&#39;s what I will try first - simple serialization with show and<br>
read, not worrying about memory. <br>Thanks!<br><br>