Chrus Chrus - 3 months ago 17
C++ Question

Does Microsoft psapi methods return bytes using decimal or binary notation?

So I just started a project thats been going on for a few years now. It uses Microsoft's psapi interface to obtain memory data. I started working on it under the assumption that the data we collected was stored in binary notation (i.e a kilobyte is 1024 bytes).

But I noticed that everything they already wrote was under the assumption that the data was in decinal notation (a kilobyte is 1000 bytes). When I asked noone knew which form the data was really in and so far my google searches hasn't shed any light on this.

More specifically we are using GetProcessMemoryInfo (https://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx)

Edit after choosing answer: So I just had a misunderstanding about what a byte was in decimal vs binary (e.g. they're the same thing). I'm just surprised noone that I asked here corrected me. Anyways thanks for clearing it up

Answer

This API returns numbers of bytes. In other words, the question is based on the false premise that values are returned in kilobytes. The distinction you refer to between binary and decimal quantities applies to kilobytes, megabytes, gigabytes etc. It is a meaningless distinction for bytes.

Documentation can be found here:

You will see members of these structures described like this:

PeakWorkingSetSize

The peak working set size, in bytes.

I've only included one example, but they are all of the same form.

Now, if you choose to present these values as kilobytes, or megabytes, or whatever, you have freedom to use whatever definition you choose.

Comments