Consider the following object
class someObject;
{
public objectA A{get;set;}
public objectB B{get;set;}
public objectC C{get;set;}
public objectD D{get;set;}
//...
}
at some point ObjectD is not needed anymore but the Instance of someObject still exist and will do so for couple hours, objectD takes up alot of memory so after its role is done i did set it up to null.
ObjectD as soon as
i set it to null?does that mean the memory will get freed from ObjectD as soon as I set it to null?
It's not object sets to null - its reference to object in memory sets to null. And object will exist until Garbage Collector will collect it (if you don't have any other references to this object).
Take a look on Fundamentals of Garbage Collection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With