Wednesday, April 27, 2005

ObjectInstance

We'll use the term ObjectInstance for the data structure located at the address pointed to by the object reference.

Before an object instance is created, the CLR looks up the loaded types, loads the type if not found, obtains the MethodTable address, creates the object instance, and populates the object instance with the TypeHandle value. The JIT compiler-generated code uses TypeHandle to locate the MethodTable for method dispatching. The CLR uses TypeHandle whenever it has to backtrack to the loaded type through MethodTable.

A typical object instance layout is as follows.
  • An index (a 1-based syncblk number, DWORD) into a SyncTableEntry table. For most object instances, there will be no storage allocated for the actual SyncBlock and the syncblk number will be zero. This will change when the execution thread hits statements like lock(obj) or obj.GetHashCode.
  • The TypeHandle that points to the MethodTable of the corresponding type.
  • A variable list of instance fields. The lexical sequence of member variables in the source code is not maintained in memory by default.
  • String literals

An object can be referenced from stack-based local variables, handle tables in the interop or P/Invoke scenarios, from registers (the this pointer and method arguments while executing a method), or from the finalizer queue for objects having finalizer methods. The OBJECTREF does not point to the beginning of the Object Instance but at a DWORD offset (4 bytes).

ObjSize (SOS command) will not include the memory taken up by the syncblk infrastructure. Also, in the .NET Framework 1.1, the CLR is not aware of the memory taken up by any unmanaged resources like GDI objects, COM objects, file handles, and so on.

Again all the notes above are taken from the article JIT and Run: Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects by Hanu Kommalapati and Tom Christian.

2 Comments:

At 5:14 PM, Blogger Unknown said...

coach outlet, ugg boots, vans pas cher, michael kors, hollister, coach purses, nike air max, ray ban uk, sac guess, ray ban pas cher, mulberry, true religion outlet, hermes, michael kors outlet, oakley pas cher, true religion jeans, lacoste pas cher, ugg boots, michael kors outlet, michael kors outlet, true religion jeans, nike free run uk, tn pas cher, michael kors, nike air max, burberry, vanessa bruno, lululemon, nike roshe, nike air max, ralph lauren uk, coach outlet, north face, replica handbags, nike blazer, converse pas cher, michael kors outlet, timberland, michael kors, abercrombie and fitch, hollister pas cher, true religion jeans, air force, burberry outlet online, michael kors, michael kors outlet, new balance pas cher, north face, kate spade handbags, hogan

 
At 5:16 PM, Blogger Unknown said...

mont blanc, nike air max, babyliss, mcm handbags, louboutin, herve leger, ghd, hollister, celine handbags, lancel, new balance, nike trainers, valentino shoes, nfl jerseys, reebok shoes, soccer shoes, oakley, vans shoes, p90x workout, soccer jerseys, nike huarache, converse outlet, nike roshe, abercrombie and fitch, bottega veneta, north face outlet, beats by dre, birkin bag, instyler, gucci, mac cosmetics, chi flat iron, ferragamo shoes, insanity workout, ralph lauren, nike air max, jimmy choo shoes, longchamp, wedding dresses, asics running shoes, vans, hollister, timberland boots, iphone cases, baseball bats, hollister, giuseppe zanotti, north face outlet, ray ban, lululemon

 

Post a Comment

<< Home