I have read a lot of .NET performance articles that describe Gen1,Gen2 garbage collection and objects surviving the generations.
Why does objects survives the collection?
What is pinning?
How do I learn more about this?
I have read a lot of .NET performance articles that describe Gen1,Gen2 garbage collection and objects surviving the generations.
Why does objects survives the collection?
What is pinning?
How do I learn more about this?
http://blogs.msdn.com/maoni/ is a good resource.
Asking questions here helps too :)
For your questions:
Why do objects survive the collection:
Objects survive a collection when they are "live objects", or "Reachable objects". Reachable objects are objects where there is a reference to them from another object that is on:
What is Pinning:
Pinning means making sure the object doesn't move in memory. objects move in memory as a result of a compacting GC, you can create a GCHandle of typed pinned if you want to pin an object, pinning also happens automatically behind the sciene for objects that are passed to native code via PInvoke ( like strings that are passed as output, the internal buffer gets pinned during the call to PInvoke ).
Check out http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.gchandle.aspx for a good example about GCHandle.