Re: memory leak or not?



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
.



Relevant Pages

  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: regexp non-greedy matching bug?
    ... pattern in question. ... >> non-greedy or minimal fashion... ... this pattern doesn't look for one or two instances of "foo" in ... It looks for a string that starts with "foo" and maybe has a ...
    (comp.lang.python)