Let's say we have the following code in a class:
//class code
TextBox t = new TextBox();
ListBox l = new ListBox();
We have then two possible situations:
In the first, we declare qem1
as a class variable(or attribute, as they call it in the Java World):
//class variable
QuickEntryMediator qem1 = new QuickEntryMediator(t,l);
In the second, we declare it inside a method:
//method variable
QuickEntryMediator qem2 = new QuickEntryMediator(t,l);
So, I'd say qem1 would never be Garbage Collected before the class goes out of scope while in the qem2 might be Garbage Collected at any time after the method in which it resides dies. Is this true?
I am looking for answers for both C#(.net) and Java, as am I am not sure both GC's work in the same fashion!
Thanks