Memory allocation in D

BCS ao at pathlink.com
Wed Nov 28 18:22:49 PST 2007


Reply to Marius,

> Hi,
> 
> I'm working on a program that is computationally and memory intensive.
> I have noticed that if I allocate the memory using D's new operator I
> can allocate only about half as much memory compared to C's malloc
> (and also the memory allocation is much slower). Does anybody know why
> D's memory allocator uses twice as much memory compared to malloc?
> 
[...]
>
> When the above program uses the test_d_alloc() function it executes
> the loop about half as many times compared to when it's using the
> test_malloc() function (until it terminates with an out of memory
> error). Also when the allocation is done in smaller increments
> (ALLOC_SIZE is smaller) the test_d_alloc() version segfaults after
> allocating the maximum amount of memory (3G) instead of terminating
> with a nice OutOfMemory error.
> 

If you are using windows and the D new version allocates 3GB of ram then 
it's using everything it can get. No matter what, you have 75% of the address 
space, I would suspect that the malloc isn't actual allocating as much as 
it should. Or am I reading something wrong. 





More information about the Digitalmars-d mailing list