Created
September 20, 2013 02:48
-
-
Save Fhernd/6632708 to your computer and use it in GitHub Desktop.
Código de demostración del recolector de basura.
This file contains 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
using System; | |
using System.Text; | |
class PruebaGarbageCollector | |
{ | |
static void Main() | |
{ | |
StringBuilder ref1 = new StringBuilder("objeto no. 1"); | |
Console.WriteLine(ref1); | |
// En este punto la referencia ref1 de tipo StringBuilder es candidato para el GC | |
StringBuilder ref2 = new StringBuilder("objeto no. 2"); | |
StringBuilder ref3 = ref2; | |
// En este punto la referencia ref2 NO es candidato para el GC. | |
Console.WriteLine(ref2); // objeto no. 2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment