Re: memory leak or not?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 3 Nov 2006 17:56:34 -0000
Cor Ligthert [MVP] <notmyfirstname@xxxxxxxxx> wrote:
My text was not meant as you read it.
I was implying that there was a new object instanced, and not only a new
reference to an existing object.
You can't possibly know whether a new object was created or not.
object A = MyJonObject;
is different from
string A = MyJonObject.ToString();
I didn't call ToString() though - I called GrabSomeLongString(). We
don't know whether that method would create a new string or not - but
either way, the value of the variable would certainly be a reference.
As it had been a "normal" reference type the object would in my idea not be
garbaged. (As it is not done in this case, to but the created string is
again a new object and that will be garbaged)
String *is* a "normal" reference type. Its immutability has nothing to
do with ths.
Marina was in my idea talking about normal non immutable reference types.
However I can of course not speak for here. Your sample is in my idea an
exception to the standard behaviour..
Not at all. There's nothing special about string here. You could change
string to any other type in my example and the behaviour would be the
same.
--
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: Cor Ligthert [MVP]
- Re: memory leak or not?
- References:
- Re: memory leak or not?
- From: Marina Levit [MVP]
- Re: memory leak or not?
- From: Jon Skeet [C# MVP]
- Re: memory leak or not?
- From: Cor Ligthert [MVP]
- Re: memory leak or not?
- From: Jon Skeet [C# MVP]
- Re: memory leak or not?
- From: Cor Ligthert [MVP]
- Re: memory leak or not?
- From: Jon Skeet [C# MVP]
- Re: memory leak or not?
- From: Cor Ligthert [MVP]
- Re: memory leak or not?
- Prev by Date: Why can't I call a parameterless-constructor from a baseclass ?
- Next by Date: Re: Why can't I call a parameterless-constructor from a baseclass ?
- Previous by thread: Re: memory leak or not?
- Next by thread: Re: memory leak or not?
- Index(es):
Relevant Pages
|