[phobos] Phobos unit tests running out of memory

Rainer Schuetze r.sagitario at gmx.de
Tue Sep 4 15:39:07 PDT 2012

On 05.09.2012 00:07, Andrei Alexandrescu wrote:
> On 9/4/12 9:38 PM, Rainer Schuetze wrote:
>> IIRC it was removed because compile times more than doubled.
> That always struck me as a simple parameter choosing problem. Can't we
> set the limit at which the GC enters in action high enough so only the
> few programs that really need a lot of RAM actually incur a collection?
> What am I missing?
>> Regarding the bail out with less than 1 GB allocated I suspect that the
>> dmc runtime uses VirtualAlloc with sizes below the allocation
>> granularity (which is 64kB on 32-bit windows). This waists virtual
>> address space, so another allocation fails even if the actually
>> allocated physical memory is well below the 2GB limit.
>> The MS-cl-compiled version of dmd does not exhibit this problem (and
>> compiles D code considerably faster).
> Interesting. Can we fix that?

If I read the dmc runtime library sources correctly (heap32/heap.cpp), 
heap allocations work with a minimum chunk size of 64 kB but 
unfortunately 4 bytes get added to the requested size before calling 
VirtualAlloc. That actually blocks 128kB of virtual address space, but 
only 64k+4 bytes are used.

So, I recommend just aligning to the next multiple of 64kB in 
RTLHeap::MoreCore. Walter, can you rebuild snn.lib with an appropriate fix?

More information about the phobos mailing list