why does this not reach $StringBuilder.MaxCapacity (either 2GB) in Windows's Powershell ?
$StringBuilder = [System.Text.StringBuilder]::new()
$nu_s = 0
$nu = 100000000
while ( $null -ne $StringBuilder.Append([char[]]::new($nu)).ToString() ) {
$nu_s = $nu_s + $nu
}
while ($nu -gt 1) {
# $null = $StringBuilder.Remove($nu_s, $StringBuilder.Length - $nu_s)
$nu = $nu / 10
while ( $null -ne $StringBuilder.Append([char[]]::new($nu)).ToString() ) {
$nu_s = $nu_s + $nu
}
}
Write-Host $nu_s, $StringBuilder.MaxCapacity
$StringBuilder.Clear()
i suppose this is related to some memory limits in P, does anyone know which that is and how to fix ?
edit_1: ~~also, the StringBuilder's Constructor doesn't accept values higher than the script provide .~~ ( it does, but still less than $StringBuilder.MaxCapacity )
edit_2: i tried using [GC]::Collect(), [GC]::WaitForPendingFinalizers() and $v.Finalize(), no changes .
edit_3: im giving up, the s**t P refuses to allow to fix this . im going with all-cases string and array limits: 200 000 000 Bytes/items; and preferable: 100 000 000 Bytes/items . (i had this issue with array-related scripts too)