-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdemo7-memory.ps1
49 lines (34 loc) · 830 Bytes
/
demo7-memory.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
cd $PSScriptRoot
get-module profiler | remove-module
import-module .\Profiler\Profiler.psd1
$sb = {
function Invoke-GC ($generation) { [gc]::Collect($generation, [System.GCCollectionMode]::Forced) }
Invoke-GC 0
Invoke-GC 1
Invoke-GC 2
$a = "abc"
function f ($Level) {
if ($Level -gt 10) {
return
}
Invoke-GC 0 # rec
$p = Get-Process # rec
Start-Sleep -Milliseconds 10
$Level
f -Level ($Level + 1)
}
f 0; f 0
$b = [System.Collections.Generic.List[int]]::new(1000)
$d = @()
foreach ($i in 1..1000) {
$d += $i
$b.Add($i)
}
$b.Add($i)
$p = Get-Process
$p = Get-Process
$p = Get-Process
$p = Get-Process
}
$trace = Trace-Script $sb
$trace.Top50SelfMemory