Re: Struct inside class
- From: "Michael D. Ober" <obermd.@.alum.mit.edu.nospam>
- Date: Thu, 01 Jun 2006 11:41:55 GMT
I missed the second question as I couldn't get a clean download until this
morning. Sorry about that. As you have already discovered, boxing requires
additional code and an additional call into the memory manager. There will
be analogous code on the outbound side of the box as well. Boxing not only
takes additional code, but it also takes additional memory since the runtime
must store the metadata for the variable as well.
Mike.
"Sneil" <at@xxxxxxx> wrote in message
news:e%23l%23yxOhGHA.4144@xxxxxxxxxxxxxxxxxxxxxxx
WOW! It's just amazing answer, almost little article. :) Great thanks
for it!
Michael D. Ober wrote:
It is relative to the value in register DS, which is set at
application startup by the memory manager. As you should be able to
see from the assembler code, there is no "boxing" of the variables.
Boxing requires a rather expensive call to determine an object's
actual data type.
Yes, you absolutely right - up to this point no any boxing. But my
second question was:
.....
myClass.s.i1 = 999;
myClass.s.i2 = 888;
object o = myClass.s.i1; //<< is boxing _here_?
Now I am sure - it IS. I see it in Reflector:
.....
L_001d: ldc.i4 888
L_0022: stfld int32 _111_.S::i2
L_0027: ldloc.0
L_0028: ldflda _111_.S _111_.C::s
L_002d: ldfld int32 _111_.S::i1
L_0037: stloc.1L_0032: _box int32_
.....
So - in spite of the fact that i1 already in heap it can not be stored
in the variable o, so boxing it is inevitable.
.
- Prev by Date: Re: Serializing/Deserializing to Database
- Next by Date: Re: Struct inside class
- Previous by thread: Re: Struct inside class
- Next by thread: Re: Struct inside class
- Index(es):