Re: memory leak or not?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 1 Nov 2006 22:18:56 -0000
Marina Levit [MVP] <someone@xxxxxxxxxx> wrote:
No, when the variable is out of scope, it becomes eligible for garbage
collection.
In this particular case it's true, but in a more general case it can be
earlier. For instance:
void Foo()
{
string x = GrabSomeLongString();
Console.WriteLine (x.Length);
// Lots more code here
// Nothing referring to x
// End of method
}
The variable "x" does not prevent the long string from being garbage
collected (in release mode) before the end of the method, even though
it's still in scope.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: memory leak or not?
- From: Sericinus hunter
- Re: memory leak or not?
- From: Cor Ligthert [MVP]
- Re: memory leak or not?
- References:
- Re: memory leak or not?
- From: Marina Levit [MVP]
- Re: memory leak or not?
- Prev by Date: Re: immutable
- Next by Date: Re: Java System.currentTimeMillis() equivalent
- Previous by thread: Re: memory leak or not?
- Next by thread: Re: memory leak or not?
- Index(es):
Relevant Pages
|