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

Matthew Fluet fluet at tti-c.org
Tue Apr 22 11:11:17 PDT 2008


On Tue, 22 Apr 2008, Nicolas Bertolotti wrote:
> When the failure occurs, there is still a lot of swap space available 
> ... and, as you mentioned, the virtual address space is the same on the 
> machine with 4Gb of RAM and the 2Gb one.

I could be that the different amounts of physical memory result in the 
operating system putting things at different virtual memory addresses.

> I just noticed that the failure occurs while the GC tries to allocate a 
> new heap with a "minSize" value that is actually smaller than the size 
> of the previous heap (that has just been released).

Good point; one wouldn't expect a heap resizing to fail if the minimum 
size is smaller than the size of the heap in hand.

> I have applied the following patch (just to give a try):
> --- mlton/runtime/gc/heap.c     2008-04-22 18:27:34.000000000 +0200
> +++ mltonp1/runtime/gc/heap.c   2008-04-11 19:12:58.000000000 +0200
> @@ -208,9 +208,6 @@
>                uintmaxToCommaString (backoff),
>                uintmaxToCommaString (minSize));
>     }
> +    /* Make sure we always try to allocate at least 'minSize' bytes. */
> +    if (h->size > minSize && (h->size - backoff) < minSize)
> +      backoff = h->size - minSize;
>   }
>   h->size = 0;
>   return FALSE;

I see: this causes the last round of the backoff to always try the minimum 
size.  Since minSize isn't necessarily pageSize aligned, you might want to 
tweak the conditions so that that mmap isn't attempted with a non-pageSize 
aligned value.




More information about the MLton mailing list