Quick int pointer allocation question

bearophile bearophileHUGS at lycos.com
Fri Sep 14 13:57:38 PDT 2012


Steven Schveighoffer:

> it has to do with the fact that the minimum heap block is 
> 16-bytes
> (or 4 ints wide).  Extra 3 bytes is probably for overhead and 
> static data.
>
> If instead of p = [i].ptr; you did p = new int; *p = i;
>
> You would get the same exact behavior.
>
> No way around this, unless you want to do custom allocators.

Right, maybe you told me the same thing lot of time ago. Thank 
you for saying such things again. 16 bytes are a lot, so there's 
not a lot of point in creating very small trees nodes :-)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list