#requires -Version 2
$script:last_memory_usage_byte = 0
function Get-MemoryUsage
{
$memusagebyte = [System.GC]::GetTotalMemory('forcefullcollection')
$memusageMB = $memusagebyte / 1MB
$diffbytes = $memusagebyte - $script:last_memory_usage_byte
$difftext = ''
$sign = ''
if ( $script:last_memory_usage_byte -ne 0 )
{
if ( $diffbytes -ge 0 )
{
$sign = '+'
}
$difftext = ", $sign$diffbytes"
}
Write-Host -Object ('Memory usage: {0:n1} MB ({1:n0} Bytes{2})' -f $memusageMB,$memusagebyte, $difftext)
# save last value in script global variable
$script:last_memory_usage_byte = $memusagebyte
}
PS> Get-MemoryUsage Memory usage: 6.7 MB (6,990,328 Bytes) PS> $array = 1..100000 PS> Get-MemoryUsage Memory usage: 10.2 MB (10,700,064 Bytes, +3709736) PS> Remove-Variable -Name array PS> Get-MemoryUsage Memory usage: 7.4 MB (7,792,424 Bytes, -2907640)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有