Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created September 20, 2013 02:48
Show Gist options
  • Save Fhernd/6632708 to your computer and use it in GitHub Desktop.
Save Fhernd/6632708 to your computer and use it in GitHub Desktop.
Código de demostración del recolector de basura.
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