[MLton] Crash fread(...) failed (only read 0) (Cannot allocate memory) during deepFlatten with MLton 20070826

Matthew Fluet fluet at tti-c.org
Wed Apr 30 10:34:45 PDT 2008


On Wed, 30 Apr 2008, Vesa Karvonen wrote:
> On Wed, Apr 30, 2008 at 5:44 PM, Matthew Fluet <fluet at tti-c.org> wrote:
> [...]
>>  That seems to be the case.  This would actually consume a little more
>> memory when using the copying collector, since both the from-heap and the
>> to-heap will have card/cross maps allocated within them.  And resizing heaps
>> would become a little more complicated, since the size of the card/cross map
>> is proportional to the size of the heap.
>
> Is it difficult/impossible to compute the required sizes and allocate
> (all) the heap(s) and card/cross map(s) in a single "transaction"
> (IOW, try to allocated all of them and if one allocation fails, free
> the others and try again with a smaller heap size)?

The size of the card/cross maps for a heap is a linear function of the 
heap size (plus some pageSize alignment).  The problem is that to play 
nice with the virtual memory system of the OS, we don't just malloc/free 
the heaps and maps.  At least on linux and other *nix variants, we try to 
use mmap, munmap, and mremap to resize heaps.  It isn't clear that all of 
these operations can be undone in a meaningful fashion, making it 
difficult to "transactionally" get a heap and card/cross map together.



More information about the MLton mailing list