Background
PowerShell has an useful function to read and parse XML files: [XML]
.
But reading XML files and (especially) building DOMs are memory consuming function.
Question
How much memory do you need to read XML files with [XML]
?
Methods
See http://d.hatena.ne.jp/N_Nao/20111226/1324926173 for mem.sh
.
$ cat xml.ps1 $XML = [XML](Get-Content "./test.xml") $ ls -l test.xml; ./mem.sh pwsh xml.ps1 -rw-rw-r-- 1 satob satob 7756 4月 20 01:04 test.xml 'pwsh xml.ps1' -> Max RSS = 84172 KB. $ ls -l test.xml; ./mem.sh pwsh xml.ps1 -rw-rw-r-- 1 satob satob 84556 4月 20 01:04 test.xml 'pwsh xml.ps1' -> Max RSS = 85500 KB. $ ls -l test.xml; ./mem.sh pwsh xml.ps1 -rw-rw-r-- 1 satob satob 929356 4月 20 01:05 test.xml 'pwsh xml.ps1' -> Max RSS = 118520 KB. $ ls -l test.xml; ./mem.sh pwsh xml.ps1 -rw-rw-r-- 1 satob satob 6395116 4月 20 01:06 test.xml 'pwsh xml.ps1' -> Max RSS = 368376 KB.
Result
# | (A) XML Size[KB] | (B) Memory Consumption [KB] | (C) Delta from #1-(B) | (C)/(A) |
---|---|---|---|---|
1 | 8 | 84,172 | - | - |
2 | 85 | 85,500 | 1,328 | 15.6 |
3 | 930 | 118,520 | 34,348 | 36.9 |
4 | 6,400 | 118,520 | 284,204 | 44.4 |