Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Why "lock" functionality is introduced for all the objects? Date: Tue, 28 Jun 2011 07:33:41 -0400 Organization: albasani.net Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net hk5bEp0U7Ymf+KbWMu9dVb9OQwO9qsXZNGyW7xxeZ0/J4cjA4LxlKdWZ7CBLrlRzfhOGmvechYjJOpXFZrgsgBnXaq8aLP3WDi2exaoaiIbeclQSo14Nt7i9XyFyesXu NNTP-Posting-Date: Tue, 28 Jun 2011 11:33:27 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="8TyPyQUaBc9WbLqa+e/1KMZ6/CyNtFJ4VeekwypaEdXC5OEivOrd5vVU+tE3A0M7EfOfW98nrwFFCPW/y8YG40xMZP7mhk65iLZlSn8UqbdQe6os/J7EwFYSLxyMX9y1"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:/TR+b0IkhsQwU2g2mFhBniU6pIM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5729 Alex J wrote: > I'm curious why Java designers once decided to allow every object to > be lockable (i.e. [sic] allow using lock on those). Because that makes it possible to do concurrent programming intrinsically. > 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. Well, that's your opinion. > The better decision, IMHO, would be to introduce lock/wait mechanics > for only, say, the Lockable descendants. Oh, yeah, your opinion is humble. > The current approach seems to be very simple, but is the performance > penalty so small for not be taken into an account? Yes. Nonexistent, really. > 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. No, that's not correct. Use of small objects vs. large in Java has no effect on memory pressure /per se/; it's the maintenance of live references to objects, small and large, that eats memory. Eclipse uses so much memory because of the many objects of various sizes that it must keep live. > What do you think of it? You're on the road to learning. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg