What happens when I provide MyObject obj = new MyObject ()

MyObject obj = new MyObject();

I know that the 'new' keyword will call the constructor and initialize the object in the managed heap.

My question is how the CLR does below.

  • How is this line executed by the CLR?
  • How is the memeory distributed for an object using the CLR?
  • How does the CLR determine the size of an object?
  • How does the CLR recognize this if there is no room to allocate memory for an object from the heap?
+5
source share
1 answer

(, , , ), . : (gen0, gen1, gen2) ( ) LOH ( ). , 85k , , ( gen0 gen1 gen2 ..). 85 LOH. LOH , , , OOM, . .

, , , ;.NET , . , , .

, , , . , refrence:

  • /
  • CPU
  • ( )
  • ( .NET COM/API)
  • ( )

5 - , , GC, . Customer, , Order. , . Customer .

, GC .

: . stack-reference Customer β†’ β†’ .

, 5 , GC.

, , MKK, http://msdn.microsoft.com/en-us/magazine/cc163791.aspx

:

class MyClass 
{ 
    string Test="Hello world Wazzup!"; 
    byte[] data=new byte[86000];  
}

, MyClass :

β€’ 19

β€’ 86 000 .

, , ( ), . SOH, ; LOH, 85 .

SOH , , LOH .

.

+2

All Articles