Re: memory leak or not?



Cor Ligthert [MVP] <notmyfirstname@xxxxxxxxx> wrote:
Read my whole post,

The first object A from this reply I have showed you is not garbaged as the
MyJonObject is not instanced in this method. The second will, because it
holds outside the method no reference anymore.

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

You introduced that example *after* contradicting my earlier example,
and introduced the example for no well-explained reason.

Note, however, that *again* there is nothing magical about strings
here. If you had written:

SomeOtherType x = MyJonObject.CreateSomeOtherType();

that would be exactly parallel to

string A = MyJonObject.ToString();


In other words, the fact that I used a string type is irrelevant, and
the fact that strings are immutable is irrelevant to their garbage
collection.


To make things clear:

a) there is no difference between strings and other reference types in
terms of whether variables hold reference

b) in my first example, contrary to your reply, what I was showing most
certainly *was* a reference.

And please keep answers by what I wrote; not what you have written that *I*
wrote;

I quoted your post exactly.

if we search on how many times you did that and how many times I
have asked you that when you don't understand my replies to ask specify what
I meant than we get endless messages. Not only by me by the way. I am
writting here mostly in a style expectiong that people are proffesionals not
amateurs in development and only need few words.

You are writing here in a style which is *frequently* hard to
understand - and not just by me.


Now, you have said that you believe I am wrong. Please state *exactly*,
in precise technical terms, in what way any of what I have posted in
this thread is wrong.

--
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: Larry Wall, on Tcl
    ... extensions written in something other than Tcl, ... I've been trying to identify a problem with using Tcl that garbage ... the only kind of reference ... TCL allows is a rather flimsy string token. ...
    (comp.lang.tcl)
  • Re: memory leak or not?
    ... MyJonObject is not instanced in this method. ... string A = MyJonObject.ToString; ... As it had been a "normal" reference type the object would in my idea ... a pool somewhere so won't be garbage collected until the application ...
    (microsoft.public.dotnet.languages.csharp)
  • 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)