Created
June 19, 2013 02:31
-
-
Save Fhernd/5811265 to your computer and use it in GitHub Desktop.
Uso del método estátido Collect de System.GC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
{ | |
~A() | |
{ | |
Console.WriteLine("Destruye instancia de A"); | |
} | |
} | |
class B | |
{ | |
object Ref; | |
public B(object o) | |
{ | |
Ref = o; | |
} | |
~B() | |
{ | |
Console.WriteLine("Destruye instancia de B"); | |
} | |
} | |
class PruebaColeccionadorBasura | |
{ | |
static void Main() | |
{ | |
B b = new B(new A()); | |
b = null; | |
GC.Collect(); | |
GC.WaitForPendingFinalizers(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment