When compiling the following program in VS2010, VS2008 or MonoDevelop on Windows, I get warning CS0219, \"The variable \'y\' is assigned but its value is never used\".
It could be that since x is a reference type, and is thus stored on the heap, that it would prevent garbage collection of that object until x goes out of scope.
For example:
void main(string[] args)
{
object x = new object();
while (true)
{
// Some threading stuff
// x is never garbage collected
}
}
In contrast to:
void main(string[] args)
{
new object();
while (true)
{
// Some threading stuff
// The unreferenced object IS garbage collected
}
}