Getting memory size of class

js.mdnq js_adddot+mdng at gmail.com
Wed Dec 5 11:03:29 PST 2012


sizeof always returns 4 or 8 regardless of size of class:

class myclass(T)
{
public:
    T v1;
    T v2;
    T v3;
    T v4;
    T v5;
    T v6;
}

writeln((myclass!byte).sizeof, (myclass!double).sizeof);

or even

writeln((myclass!int).classinfo.init.sizeof, 
(myclass!double).classinfo.init.sizeof);

from

http://forum.dlang.org/thread/dp9hct$nuf$1@digitaldaemon.com

So how does one get the actual memory usage of a class?


More information about the Digitalmars-d-learn mailing list