OK, without reallocation:

====================8<====================
void main()
{
    float[3] f;
    float[3][] x;
    writefln("float = %s bytes", float.sizeof);
    writefln("float[3] = %s bytes", f.sizeof);

    int before = MemoryUsage();

    int total = 100;
    x = new float[3][total*1000];

    int after = MemoryUsage();
    writefln("%dK * float[3] = %d Kbytes", total, (after-before));
}
====================>8====================

$ ./memory
float = 4 bytes
float[3] = 12 bytes
100K * float[3] = 2300 Kbytes

Why this so?

Reply via email to