2

To convert the readings in /proc/meminfo from "kB" to bytes, should I multiply by 1024, or 1000?

3
  • 1024 (one thousand twenty four).
    – kba
    Feb 17, 2016 at 16:30
  • muru - How is this a duplicate? I already know /proc/meminfo always uses kB Feb 17, 2016 at 17:20
  • 1
    And this question is for /proc/meminfo not /proc/[pid]/status...
    – olejorgenb
    Feb 3, 2017 at 3:43

1 Answer 1

3

One convention used to differentiate base 2 and base 10 representations for writing Kilobyte is using upper case K and lower case k respectively. Hence, conversion becomes:

1 KB = 1024 bytes  
1 kB = 1000 bytes

The kernel, however, uses a buddy system with power-of-two sizes. Hence, appropriate conversion becomes multiplying by 1024.

Here are some links for more information: Kernel memory handling

2
  • 1
    That maybe true for other places, but the kernel calls 1024 bytes kB and KB somewhat indiscriminately.
    – muru
    Feb 17, 2016 at 16:50
  • You are right. And I made an edit above to fix it.
    – assefamaru
    Feb 17, 2016 at 17:02

Not the answer you're looking for? Browse other questions tagged .