How do I maximize memory usage using powershell
Try this:
$mem_stress = "a" * 200MB
Edit: If cou can't allocate all memory in a single chunk, try allocating multiple chunks in an array:
$mem_stress = @()for ($i = 0; $i -lt ###; $i++) { $mem_stress += ("a" * 200MB) }
The GC doesn't seem to interfere with this (results from a quick test in a VM with 1 GB RAM assigned):
PS C:\> $a = @()PS C:\> $a += ("a" * 200MB)PS C:\> $a += ("a" * 200MB)PS C:\> $a += ("a" * 200MB)PS C:\> $a += ("a" * 200MB)The '*' operator failed: Exception of type 'System.OutOfMemoryException' was thrown..At line:1 char:13+ $a += ("a" * <<<< 200MB) + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : OperatorFailed