Thanks, both for the summary and for the link. Will try to go through it.<br><br>Regards,<br>Abhay<br><br><div class="gmail_quote">On Wed, Apr 16, 2008 at 12:37 PM, Bulat Ziganshin &lt;<a href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello Abhay,<br>
<div class="Ih2E3d"><br>
Wednesday, April 16, 2008, 10:51:07 AM, you wrote:<br>
<br>
&gt; I am not saying that it should claim it as soon as it is unused;<br>
&gt; all I am saying that as soon as a priority object becomes<br>
&gt; unreferenced, it should be the first choice for collecting in the next collect.<br>
<br>
</div>on the GC, all unreferenced objects are collected. there is no<br>
difference which ones will be collected first - anyway program is<br>
stopped until whole GC will be finished<br>
<div class="Ih2E3d"><br>
&gt; Further I was under the impression (I may be wrong) that it uses a<br>
&gt; generational GC and therefore scans allocated memory incrementally;<br>
&gt; not the whole at a time. Please correct me if I am wrong.<br>
<br>
</div>yes, it uses generational GC. data are first allocated in small 256k block<br>
and when it is filled, GC for this small block occurs. data that are<br>
still alive then moved to the global heap. this minor GC doesn&#39;t scan<br>
global heap. if it will do this, each minor GC will become as slow as<br>
major ones<br>
<br>
&quot;Generational garbage collection for Haskell&quot;<br>
<a href="http://research.microsoft.com/%7Esimonpj/Papers/gen-gc-for-haskell.ps.gz" target="_blank">http://research.microsoft.com/~simonpj/Papers/gen-gc-for-haskell.ps.gz</a><br>
<div><div></div><div class="Wj3C7c"><br>
&gt;<br>
&gt; Regards,<br>
&gt; Abhay<br>
<br>
&gt; On Wed, Apr 16, 2008 at 11:55 AM, Bulat Ziganshin<br>
&gt; &lt;<a href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</a>&gt; wrote:<br>
&gt; &nbsp;Hello Abhay,<br>
&gt;<br>
&gt; &nbsp;Wednesday, April 16, 2008, 9:30:34 AM, you wrote:<br>
&gt;<br>
&gt; &nbsp;i think it will not work with current ghc GC - it scans entire<br>
&gt; &nbsp;memory/nursery when garbage collected so anyway you will need to wait<br>
&gt; &nbsp;until next GC event occurs<br>
&gt;<br>
<br>
&nbsp;&gt;&gt; Your mail gives me an idea, though I am not an iota familiar with<br>
&nbsp;&gt;&gt; compiler/garbage collector internals. Can we have some sort of<br>
&nbsp;&gt;&gt; internally maintained priority associated with allocated objects?<br>
&nbsp;&gt;&gt; The garbage collector should look at these objects first when it<br>
&nbsp;&gt;&gt; tries to free anything. The objects which hold other system<br>
&nbsp;&gt;&gt; resources apart from memory, such as file handles, video memory, and<br>
&nbsp;&gt;&gt; so on could be allocated as higher priority objects. Is such a thing possible?<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; 2008/4/16 Conal Elliott &lt;<a href="mailto:conal@conal.net">conal@conal.net</a>&gt;:<br>
&nbsp;&gt;&gt; &nbsp;Are Haskell folks satisfied with the practical necessity of<br>
&nbsp;&gt;&gt; imperatively &amp; explicitly reclaiming resources such as file handles,<br>
&nbsp;&gt;&gt; fonts &amp; brushes, video memory chunks, etc?&nbsp; Doesn&#39;t explicit freeing<br>
&nbsp;&gt;&gt; of these resources have the same modularity and correctness problems<br>
&nbsp;&gt;&gt; as explicit freeing of system memory (C/C++ programming)?<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; I wrote a lovely purely functional graphics library that used video<br>
&nbsp;&gt;&gt; memory to lazily compute and cache infinite-resolution images, and I<br>
&nbsp;&gt;&gt; found that I don&#39;t know how to get my finalizers to run anytime soon<br>
&nbsp;&gt;&gt; after video memory chunks become inaccessible.&nbsp; Explicit freeing<br>
&nbsp;&gt;&gt; isn&#39;t an option, since the interface is functional, not imperative (IO).<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; I guess I&#39;m wondering a few things:<br>
&gt;<br>
&nbsp;&gt;&gt; * Are Haskell programmers generally content with imperative and<br>
&nbsp;&gt;&gt; bug-friendly interfaces involving explicit freeing/closing of resources?<br>
&nbsp;&gt;&gt; * Do people assume that these resources (or handling them frugally)<br>
&nbsp;&gt;&gt; aren&#39;t useful in purely functional interfaces?<br>
&nbsp;&gt;&gt; &nbsp;* Are there fundamental reasons why GC algorithms cannot usefully<br>
&nbsp;&gt;&gt; apply to resources like video memory, file descriptors, etc?<br>
&nbsp;&gt;&gt; * Are there resource management techniques that have the<br>
&nbsp;&gt;&gt; flexibility, efficiency, and accuracy of GC that I could be using for these other resources?<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; Thanks,<br>
&nbsp;&gt;&gt; &nbsp; - Conal<br>
&gt;<br>
&nbsp;&gt;&gt; 2008/4/14 Abhay Parvate &lt;<a href="mailto:abhay.parvate@gmail.com">abhay.parvate@gmail.com</a>&gt;:<br>
&nbsp;&gt;&gt; &nbsp;Hello,<br>
&gt;<br>
&nbsp;&gt;&gt; In describing the Handle type, the GHC documentation says (in the System.IO documentation):<br>
&gt;<br>
&nbsp;&gt;&gt; GHC note: a Handle will be automatically closed when the garbage<br>
&nbsp;&gt;&gt; collector detects that it has become unreferenced by the program.<br>
&nbsp;&gt;&gt; However, relying on this behaviour is not generally recommended:<br>
&nbsp;&gt;&gt; the garbage collector is unpredictable. &nbsp;If possible, use explicit<br>
&nbsp;&gt;&gt; an explicit hClose to close Handles when they are no longer<br>
&nbsp;&gt;&gt; required. &nbsp;GHC does not currently attempt to free up file<br>
&nbsp;&gt;&gt; descriptors when they have run out, it is your responsibility to &nbsp;ensure that this doesn&#39;t happen.<br>
&gt;<br>
&nbsp;&gt;&gt; But one cannot call hClose on Handles on which something like<br>
&nbsp;&gt;&gt; hGetContents has been called; it just terminates the character list<br>
&nbsp;&gt;&gt; at the point till which it has already read. Further the manual says<br>
&nbsp;&gt;&gt; that hGetContents puts the handle in the semi-closed state, and further,<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; A semi-closed handle becomes closed:<br>
&nbsp;&gt;&gt; &nbsp;if hClose is applied to it; &nbsp;if an I/O error occurs when reading<br>
&nbsp;&gt;&gt; an item from the handle; &nbsp;or once the entire contents of the handle has been read.<br>
&nbsp;&gt;&gt; So do I safely assume here, according to the third point above,<br>
&nbsp;&gt;&gt; that it&#39;s fine if I do not call hClose explicitly as far as I am<br>
&nbsp;&gt;&gt; consuming all the contents returned by hGetContents?<br>
&gt;<br>
&nbsp;&gt;&gt; Thanks,<br>
&nbsp;&gt;&gt; Abhay<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; _______________________________________________<br>
&nbsp;&gt;&gt; &nbsp;Haskell-Cafe mailing list<br>
&nbsp;&gt;&gt; &nbsp;<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&nbsp;&gt;&gt; &nbsp;<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&nbsp;&gt;&gt;<br>
&gt;<br>
&gt;<br>
&nbsp;&gt;&gt;<br>
&nbsp;&gt;&gt; _______________________________________________<br>
&nbsp;&gt;&gt; &nbsp;Haskell-Cafe mailing list<br>
&nbsp;&gt;&gt; &nbsp;<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&nbsp;&gt;&gt; &nbsp;<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&nbsp;&gt;&gt;<br>
&gt;<br>
&gt;<br>
&nbsp;&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; &nbsp;Best regards,<br>
&gt; &nbsp;&nbsp;Bulat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mailto:<a href="mailto:Bulat.Ziganshin@gmail.com">Bulat.Ziganshin@gmail.com</a><br>
&gt;<br>
&gt;<br>
<br>
&gt;<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="Wj3C7c">Best regards,<br>
&nbsp;Bulat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mailto:<a href="mailto:Bulat.Ziganshin@gmail.com">Bulat.Ziganshin@gmail.com</a><br>
<br>
</div></div></blockquote></div><br>