This is a problem with partitioned operating systems used in avionics. The airplane computers require certain partitions to exist between programs in both time and space. The space guarantees are most easily enforced by eliminating any dynamic memory allocation once the operating system enters a &#39;normal mode&#39;. This means that all memory needs to be allocated on the stack and ahead of time.<br>
<br>This reduces the calculation of the upper memory bound to checking what the largest possible stack a process could grow to is. Of course, calculating this maximum stack is difficult in its own right.<br><br>Unfortunately, nothing I&#39;ve just discussed seems to port well to Haskell (I could be wrong!). Given this, I think you&#39;re looking at a very hard problem (but one I&#39;d be incredibly interested in discovering a solution for!).<br>
<br>/jve<br><br><div class="gmail_quote">On Thu, Dec 24, 2009 at 5:38 PM, Roman Cheplyaka <span dir="ltr">&lt;<a href="mailto:roma@ro-che.info">roma@ro-che.info</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Imagine some system with hard memory bound (e.g. 64M of physical memory,<br>
no swap). I don&#39;t want some accidental laziness (maybe even not in my<br>
code, but in some used package) to crash my program.<br>
<br>
So, let&#39;s think what we can do at runtime. Suppose RTS takes the parameter --<br>
upper limit of consumed memory. When it sees that memory consumption is<br>
close to upper bound, it can:<br>
<br>
1. force garbage collection<br>
<br>
2. apply some heuristics to find and reduce some chunks which will<br>
   benefit from reduction in terms of size<br>
<br>
3. if nothing helps, throw an exeption. It can be caught in IO and<br>
   memory-aware program can make apropriate decision -- e.g. abort<br>
   opening a large file and gracefully warn the user.<br>
<br>
(And there still is a problem of foreign code whose memory consumption<br>
we know nothing about...)<br>
<br>
What do you think?<br>
<font color="#888888"><br>
--<br>
Roman I. Cheplyaka :: <a href="http://ro-che.info/" target="_blank">http://ro-che.info/</a><br>
&quot;Don&#39;t let school get in the way of your education.&quot; - Mark Twain<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></blockquote></div><br>