monarch_dodra:

int *p = [5].ptr;

-Steve

But see this benchmark:


void main() {
    auto pointers = new int*[1_000_000];
    foreach (int i, ref p; pointers)
        p = [i].ptr;
    foreach (i; 0U .. 4_000_000_000U) {}
}


On my 32 bit system its RAM commit is about 23 MB. The pointers array takes about 4 MB. This means each "int" takes about 19 bytes of heap RAM instead of 4. Each int allocates some data (capacity) to extend the array.

Bye,
bearophile

Reply via email to