Skip to content

Increasing precision for virtual memory used percent on windows#1619

Open
rayjanoka wants to merge 1 commit into
shirou:masterfrom
rayjanoka:windows_memory_precision
Open

Increasing precision for virtual memory used percent on windows#1619
rayjanoka wants to merge 1 commit into
shirou:masterfrom
rayjanoka:windows_memory_precision

Conversation

@rayjanoka
Copy link
Copy Markdown

@rayjanoka rayjanoka commented Apr 4, 2024

Hey! Nice library!!

I found that the virtualMemory.UsedPercent returned by windows is just a whole number and we lose some precision there. I computed it instead using total - available / total * 100 so we can get the same precision we see on linux.

virtMemTest - Old 28.000000 : New 28.606437
virtMemTest - Old 28.000000 : New 28.594666
virtMemTest - Old 28.000000 : New 28.637374

@shirou
Copy link
Copy Markdown
Owner

shirou commented Apr 18, 2024

Good point. Thanks you for opening this PR.

However, I noticed that psutil uses PERFORMANCE_INFORMATION instead of MEMORYSTATUSEX. So I think we should change that. After the change, the precision issue will be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants