I have a memory leak question. Will the instances of obj ever be eligible for garbage collection until the class instance of TopClass goes out of scope?
public class TopClass
{
public void MyFunction()
{
TestClass obj = new TestClass();
obj.PropertyChanged += (s,e) => { //Do some code };
obj = null;
}
}
Furthermore that would make all objects that instantiate a TopClass and invoke MyFunction() to not be eligible for GC right?
I understand that in managed code once the application goes out of scope then all the objects are eligible, but I want to know WHILE my app is running this will cause a memory leak. Right?