# Find out how much memory is being consumed by your Sesssion:
[System.gc]::gettotalmemory("forcefullcollection") /1MB
# Force a collection of memory by the garbage collector:
[System.gc]::collect()
# Dump all variables not locked by the system:
foreach ($i in (ls variable:/*)) {rv -ea 0 -verbose $i.Name}
#Check memory usage again and force another collection:
[System.gc]::gettotalmemory("forcefullcollection") /1MB
[System.gc]::collect()
#Check Memory once more:
[System.gc]::gettotalmemory("forcefullcollection") /1MB
#You can examine the difference before and after with:
ps powershell* | Select *memory*
or with something more complicated:
ps powershell* | Select *memory* | ft -auto `
@{Name='VirMemMB';Expression={($_.VirtualMemorySize64)/1MB}}, `
@{Name='PriMemMB';Expression={($_.PrivateMemorySize64)/1MB}}
VirMemMB PriMemMB
-------- --------
1548.3671875 432.43359375
603.9765625 58.5234375
No comments:
Post a Comment