I am trying to find a memory leak using ants memory profiler, and I\'ve encountered in a new term:
Pinned objects.
Can some one give me a good & simple e
The reason you might pin an object is if you are making calls to unmanaged code.
When the garbage collector runs it may remove an object that's no longer required. This leaves a "hole" of free space in the heap. The GC then compacts the heap by moving the remaining objects together to make sure the free space is in one continous block (a bit like defragmenting your hard disk).
It also updates all the references (in the managed code) to any objects that have been moved as part of the compaction.
If you are working with unmanaged code (e.g. some external C++) and give it a pointer to an object, there is no way for the GC to tell the unmanaged code that the object has moved after it has run. Therefore you might mark the object your sharing with the external code as pinned so that you don't have the problem of the pointer becoming invalid.