In my previous post, I discussed the eager root collection as an aggressive behavior of JIT (in Release mode / optimized code) to assist the garbage collector (GC), so that a object is not considered to be a root beyond the point of its usage. But sometimes we may want to extend the lifetime of an object beyond its usual lifetime. In this post, we will see an example of a scenario where we may want to extend the lifetime of an object. Also, we will look at how we can accomplish this in two ways — one is writing an API ourselves (in the spirit of learning by doing) and other is to use existing API in .NET.

#csharp #garbage-collection #dotnet-core #memory-management #dotnet #.net

Bless Your .NET Object With a Shot of Lifeline
1.45 GEEK