Re: memory leak or not?



Jon,

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.

object A = MyJonObject;
is different from
string A = MyJonObject.ToString();

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)

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..

Cor

"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> schreef in bericht
news:MPG.1fb4fd74a108f76298d5be@xxxxxxxxxxxxxxxxxxxxxxx
Cor Ligthert [MVP] <notmyfirstname@xxxxxxxxx> wrote:
Um, just because it's immutable doesn't mean that string isn't a
reference type.

That is exactly why I wrote it.

But you implied that string isn't a reference type. It is. You wrote:

<quote>
The string is immutable what you are showing is not a reference.
</quote>

What I was showing most certainly *is* a reference.

--
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: String Reference Type
    ... pointer to the value. ... lblClassName name to "My String". ... everything else is a true object and thus a reference type. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: String Reference Type
    ... pointer to the value. ... lblClassName name to "My String". ... everything else is a true object and thus a reference type. ...
    (microsoft.public.dotnet.framework.aspnet)
  • 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)