Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.machine > #13

Why "lock" functionality is introduced for all the objects?

From Alex J <vstrength@gmail.com>
Newsgroups comp.lang.java.machine
Subject Why "lock" functionality is introduced for all the objects?
Date 2011-06-28 02:30 -0700
Organization http://groups.google.com
Message-ID <736a142e-85ae-4790-a1f1-afb09bfed755@em7g2000vbb.googlegroups.com> (permalink)

Show all headers | View raw


I'm curious why Java designers once decided to allow every object to
be lockable (i.e. allow using lock on those).
I know, that out of such a design decision every Java object contain
lock index, i.e. new Object() results in allocation of at least 8
bytes where 4 bytes is object index and 4 bytes is lock index on 32-
bit JVM.
I think that it just inefficient waste of space, because not all the
objects requires to be lockable/waitable.

The better decision, IMHO, would be to introduce lock/wait mechanics
for only, say, the Lockable descendants.
The current approach seems to be very simple, but is the performance
penalty so small for not be taken into an account?
Eclipse uses tons of small objects and I guess that is why it consumes
so much memory while a significant part of it is never used.

What do you think of it?

Back to comp.lang.java.machine | Previous | NextNext in thread | Find similar


Thread

Why "lock" functionality is introduced for all the objects? Alex J <vstrength@gmail.com> - 2011-06-28 02:30 -0700
  Re: Why "lock" functionality is introduced for all the objects? Roedy Green <see_website@mindprod.com.invalid> - 2011-06-28 10:02 -0700
  Re: Why "lock" functionality is introduced for all the objects? Barb Knox <see@sig.below> - 2011-06-30 18:11 +1200

csiph-web