Usage of memory by arrays
unDEFER
undefer at gmail.com
Thu Apr 5 21:44:35 UTC 2018
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?
More information about the Digitalmars-d
mailing list