Re: memory leak or not?



Jon,

I think you are wrong, however it does nothing add to the question from the
OP.

In my opinion was the reply from Marina more than enough,

So I stop this discussion.

Cor

"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> schreef in bericht
news:MPG.1fb5932e29281cd198d5c2@xxxxxxxxxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: Complex Specified Information - Pitman Formula
    ... Therefore a significant match between a reference and a test ... string is good evidence of non-random production. ... and there are no finite algorithms to compute their digits. ... probabilities of the different symbols the information source can produce. ...
    (talk.origins)
  • Re: String Reference Type
    ... All unary and binary operators have predefined implementations that are ... Therefore its always allocated in the heap and a variable of string ... As with all classes in this case y and x both reference the same String ... language depandant matter as below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Abstract class variables question
    ... But as I think you've seen elsewhere in this thread, a value type can exist inside a class and in that case the value type is stored in the heap with the rest of the class instance. ... But as far as the "faster" goes, yes...to some extent value types have less overhead than reference types, and so can perform better in certain cases. ... Well, that would be true for a string object too, if there was any way to actually change a string. ... Seriously though, it is practically always the case that when you are writing an assignment to a reference, you're replacing the reference held by the variable. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Measurement of pitch
    ... as the method used by the Pythagoreans. ... of these reference units in the quantity to be measured. ... vibrating string seems as good as anything. ... The string or pendulum in question could no doubt be specified exactly, ...
    (sci.physics)
  • Re: Abstract class variables question
    ... I think I understand boxing a little better now. ... the object that is on the heap. ... value types are copied to the heap and made into an object and reference ... String types are already reference types and all we are doing when we do ...
    (microsoft.public.dotnet.languages.csharp)