Mono Class Library: System.GC Overview | MembersSystem.GC.KeepAlive Method |
Creates a reference to the specified object. [Edit]
|
The purpose of the GC.KeepAlive(object) method is to ensure the existence of a reference to an object that is at risk of being reclaimed by the garbage collector prematurely.
The GC.KeepAlive(object) method performs no operations and does not produce any side effects.
This method is required to be implemented in such a way as to prevent optimizing tools from omitting the method call from the executable code.
During program execution, after the call to the GC.KeepAlive(object) method is executed, if there are no additional references to obj in managed code or data, obj is eligible for garbage collection.
[Edit]
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0