It's useful and necessary in the same situations as it was in VBScript.
Cleanup in VBScript happened anyway for scoped data - for example, objects
and other data used within functions automatically went away after the
function went out of scope. The same thing happens in PowerShell when you're
using functions and scripts; whether or not you explicitly discard data in a
subscope, unused references and variables get tossed and are eventually
garbage-collected.
So generally, it doesn't matter. The one place that it _can_ be a problem is
if you're using PowerShell interactively and start collecting large amounts
of output into variables. Those can suck down memory fairly fast. However,
it generally doesn't seem to show up as a problem. I believe that's because
most people don't bother with collecting data into variables during
interactive sessions. Instead they may just run a command and see the
output - in which case data goes away immediately - or they may use the
pipeline to process large data sets item-by-item. In the latter case, you
generally never get a large bulge of in-memory stored data.
"James" <noone@xxxxxx> wrote in message
news:eoq9VmmyJHA.1372@xxxxxx
> Hello,
>
> coming from vbscript where it was good practice to 'clean up', as in:
>
> set myVar = CreateObject("someObject")
> ...
> ...
> then when done:
> set myVar = Nothing
>
> which would free up that memory. Now, powershell is .net under the hood,
> so is this clean up still necessary? or does .net garbage collection
> handle everything?