optional reduction of overhead for classes
Tom S
h3r3tic at -remove-.mat.uni.torun.pl
Mon Apr 17 13:41:18 PDT 2006
clayasaurus wrote:
> class EntityData
> {
> float x, y;
> }
>
> ------------------------------------------------------------------------
>
> My question is, how much memory does EntityData use before allocation
> (4-bytes?), and how much does it use after allocation (4+4+4 bytes total?).
Well, before allocation, your EntityData doesn't really exist, only a
null reference, which takes 4 bytes on 32 bit systems. IIRC, you can
check the size of an object thru .classinfo.init.length.
If you want to avoid overhead, consider making EntityData a struct, to
which you'd store a pointer.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d-pu s+: a-->----- C+++$>++++ UL P+ L+ E--- W++ N++ o? K? w++ !O
!M V? PS- PE- Y PGP t 5 X? R tv-- b DI- D+ G e>+++ h>++ !r !y
------END GEEK CODE BLOCK------
Tomasz Stachowiak /+ a.k.a. h3r3tic +/
More information about the Digitalmars-d-learn
mailing list