Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: supercalifragilisticexpialadiamaticonormalizeringelimatisticantations Newsgroups: comp.lang.java.programmer Subject: Re: Why "lock" functionality is introduced for all the objects? Date: Wed, 06 Jul 2011 05:55:07 -0400 Organization: supercalifragilisticexpialadiamaticonormalizeringelimatisticantations Lines: 27 Message-ID: References: <3d0a7034-5e01-476c-926d-1b99ab071357@x12g2000yql.googlegroups.com> NNTP-Posting-Host: 3YDAuD+aHzH3oDO5mYkDPw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: WinVN 0.99.12z (x86 32bit) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5889 On 05/07/2011 7:56 PM, Alex J wrote: > public class Foo { > private int a; > > private int b; ... > > public class Bar { > private int a; > > private Integer b; // this is the only difference between Bar and > Foo. ... > using Integer instead of int results in extra 32 > bytes allocation per each object. WTF? I'd have expected 12: 8 for the Integer's object header and 4 for its int field, the b fields in both Foo and Bar being 4 bytes so no change there. Somewhere there's an extra 20 bytes per Bar or even per Integer being gobbled up.