Re: Garbage Collection - dim x as y versus dim x as new y

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



thank you michel. If an object or type goes out of scope, it is elgible for
garbage collection. I like that simple concept.
-greg

"m.posseth" <michelp@xxxxxxxxxxxxxxx> wrote in message
news:e$3cqyglFHA.1372@xxxxxxxxxxxxxxxxxxxxxxx
> Well if the object goes out of scope it will automaticly be released
> although i am still one of those people who like to set object pointers to
> Nothing
>
>
> however in the example you gave setting it to a new object pointer is
> sufficient
>
> dim x as new y
> try
> x.foo()
>
>
>
> ' dim x as y ------- this is not necessary as the declaraion is above the
> try statement it is still in scope
> try
> x = new y
> x.foo()
>
>
> regards
>
> Michel Posseth
>
>
>
>
> "hazz" <hazz@sonic_net> wrote in message
> news:%235MnmoglFHA.1148@xxxxxxxxxxxxxxxxxxxxxxx
>> with respect to garbage collection. Does it make any difference? My
>> current understanding is that (to avoid memory leaks, ie memory
>> accumulation - never letting go of the memory something has referenced)
>> it isn't so much HOW an object reference (or string or byte())
>> is created, it is more about no longer having a reference to an object or
>> other type.
>> If so, how do I remove a reference to something when I no longer need it?
>> thx, -hazz
>>
>> dim x as new y
>> try
>> x.foo()
>>
>>
>>
>> dim x as y
>> try
>> x = new y
>> x.foo()
>>
>>
>>
>>
>
>


.



Relevant Pages

  • Re: general performance question
    ... (It seems to me that the JVM should be free to null out the reference once it goes out of scope, or even if it's in scope but flow analysis makes it clear that it can't be used any more, but that was a minority opinion.) ... If you create an Object in a loop and then reassign another Object to the same reference in the loop, the first Object is eligible for garbage collection. ...
    (comp.lang.java.programmer)
  • Re: argument returning
    ... because there is still a live reference to it. ... long as the variable is in scope, ... The object will only be eligible for garbage collection ... Matt Humphrey matth@xxxxxxxxxxxxxx http://www.iviz.com/ ...
    (comp.lang.java.programmer)
  • Re: GC and active sockets, and Pinned Memory
    ... once an object goes out of scope and effectively ... is unreachable through any means available to developer, ... reference A goes away but reference B is still there. ... >> Garbage collection timer is there to ensure garbage collection is forced ...
    (microsoft.public.dotnet.framework)
  • Re: GC and active sockets, and Pinned Memory
    ... Objects don't go out of scope, references do go out of scope. ... Your local references go out of scope, but as YOU passed a NetworkStream ... thread pool which stores the NetworkStream reference for later use, ... >>> Garbage collection timer is there to ensure garbage collection is ...
    (microsoft.public.dotnet.framework)
  • Re: vbs output to txt file
    ... the reference count to that object will be decremented. ... As does going out of scope:) ... You are religiously setting objects to nothing and not ... and so am seriously lacking in both scripting expertise ...
    (microsoft.public.scripting.wsh)