Powershell is a managed App... The GC process should clean up memory.
After you remove the variable try this
# This will force the Garbage Collection Process
[GC]::Collect()
And then check again
Brandon Shell
---------------
Blog:
http://www.bsonposh.com/
PSH Scripts Project:
www.codeplex.com/psobject
k> Is there any method short of exiting PowerShell and restarting it to
k> release memory used by varialbes?
k>
k> For this example I'm using the Quest ActiveRoles commandlets, however
k> I do not believe this is related to those commandlets specifically.
k>
k> If I do "$groups = get-qadgroup", which returns the first 1000 groups
k> found in AD, I use roughly 6MB of memory. This isn't too bad by
k> iteself. However if I were to pass the "-SizeLimit 0" parameter as
k> part of the command the impact would be much more severe in larger
k> environments. I witnessed the PowerShell process grow to over 300MB
k> following a "$users = get-qaduser -SizeLimit 0" earlier.
k>
k> I tried two methods to release this memory. First I set $groups =
k> $null, which had no impact. Next I tried "remove-variable groups".
k> Again, no impact on memory utilization.
k>
k> Closing PowerShell does give back all of the memory. Is this the only
k> way?
k>