Try the following:
$mem_stress = "a" * 200MB
Edit: If ku cannot allocate all the memory in one fragment, try allocating several blocks in the array:
$mem_stress = @() for ($i = 0; $i -lt
GC does not seem to interfere with this (results of a quick test on a virtual machine with 1 GB of 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
source share