object sync monitor ref

Pavel phondogo at gmail.com
Thu Nov 7 02:35:11 PST 2013


Hello!

For every object of class there is two pointers (for vtable and 
monitor).
I wonder why there is a need to have sync functionality in object 
(1 pointer memory waste).
There is also such overhead in Java and during my work with it I 
use synchronized section only for about 0.01% of all objects in 
program (may be even less). So 99.99% of objects just waste 
memory for that monitor pointer.

Why don't to introduce some annotation (property) for class 
needed to be synchronized or it descendants, according to it 
compiler will extend the size of class by the size of monitor 
structure (+1 allocation less).
Synchronization will be allowed when class or supers is annotated 
with this property (it can be checked by compiler).





More information about the Digitalmars-d mailing list