<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.newlc.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>NewLC - Estimate the Size of a Class/Object - Comments</title>
 <link>http://www.newlc.com/Estimate-the-Size-of-a-Class.html</link>
 <description>Comments for &quot;Estimate the Size of a Class/Object&quot;</description>
 <language>en</language>
<item>
 <title>&gt; Estimate the Size of a Class/Object</title>
 <link>http://www.newlc.com/Estimate-the-Size-of-a-Class.html#comment-2369</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;&gt;&gt;Hi Girish, 1. I think in the first bullet iMem3 should be replaced by iMem4, becauuse iMem4 is static member. 
Yeah, you are right, another mistake there, The whole sentense should be replaced by&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;Defination of Class remains same, there is some correction in the below line:&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;For this class A, size will be, sizeof (float iMem1+ int iMem2+char &lt;strong class=&quot;spip&quot;&gt;iMem4&lt;/strong&gt;); Static members are really not part of Class. They wont be included in Class/Object layout.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;&gt;&gt;2. If you can add one more bullet regarding the size of empty class
Yeah, can add more on size of Empty class.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;Size of Empty class will be a byte (minimum memory that can be accessed). Its because, suppose we have a class with out any members in that, then theoratically, its as good as class with size 0. But it does not make any sense practically.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;class EmptyClass&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;&lt;i class=&quot;spip&quot;&gt;&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;&lt;/i&gt;;&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;When someone instantiates an object of that class, if the size is 0, then its as good as refering to something which is not existing!
Lets say, I have two objects of EmptyClass, obj1, obj2. What should happen when I do, obj1 = obj2; ? We dont have any existance for these objects !! So, compiler will keep 1 byte of memory for Empty class&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;Regards
Girish&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 09 Sep 2005 06:53:34 +0200</pubDate>
 <dc:creator>Anonymous</dc:creator>
 <guid isPermaLink="false">comment 2369 at http://www.newlc.com</guid>
</item>
<item>
 <title>&gt; Estimate the Size of a Class/Object</title>
 <link>http://www.newlc.com/Estimate-the-Size-of-a-Class.html#comment-2368</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;Hi Girish,
1. I think in the first bullet iMem3 should be replaced by iMem4, becauuse iMem4 is static member.
2. If you can add one more bullet regarding the size of empty class&lt;/div&gt;</description>
 <pubDate>Fri, 09 Sep 2005 06:35:47 +0200</pubDate>
 <dc:creator>Anonymous</dc:creator>
 <guid isPermaLink="false">comment 2368 at http://www.newlc.com</guid>
</item>
<item>
 <title>&gt; Estimate the Size of a Class/Object</title>
 <link>http://www.newlc.com/Estimate-the-Size-of-a-Class.html#comment-2367</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;I would like to add that the empty base class optimization (EBCO) may reduce the size in some cases.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;A tip: because sizeof( ClassName ) is a compile-time constant, you can find out the value by compiling. You can do like this:
&lt;tt&gt;&lt;div align=&#039;left&#039; class=&#039;spip_code&#039; dir=&#039;ltr&#039;&gt;switch(1)&lt;br /&gt;
{&lt;br /&gt;
case 1:&lt;br /&gt;
case 2:&lt;br /&gt;
case 3:&lt;br /&gt;
case 4:&lt;br /&gt;
... etc.&lt;br /&gt;
&lt;br /&gt;
case sizeof( ClassName ):&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;&lt;/tt&gt;&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;When you compile, you&#039;ll get an error like &quot;error C2196: case value &#039;20&#039; already used&quot;. In that case, the sizeof( ClassName ) is 20 bytes.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;Or alternatively, you can write a C++ template to do the same without a long switch statement.&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 05 Sep 2005 11:48:57 +0200</pubDate>
 <dc:creator>Late</dc:creator>
 <guid isPermaLink="false">comment 2367 at http://www.newlc.com</guid>
</item>
<item>
 <title>Estimate the Size of a Class/Object</title>
 <link>http://www.newlc.com/Estimate-the-Size-of-a-Class.html</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;This tutorial will teach you how to estimate and optimize the size of the class you write. Quite useful as you will learn that they may not be the same on the emulator and the target....&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/Estimate-the-Size-of-a-Class.html&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/Estimate-the-Size-of-a-Class.html#comments</comments>
 <category domain="http://www.newlc.com/taxonomy/term/18">Tips</category>
 <category domain="http://www.newlc.com/taxonomy/term/137">Memory Management</category>
 <pubDate>Fri, 02 Sep 2005 18:15:14 +0200</pubDate>
 <dc:creator>girishshetty</dc:creator>
 <guid isPermaLink="false">669 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
