3

I need to get total RAM size in gigabytes (e.g. 8 GB or 8.0 GB). It gives as bytes and I convert it into GB by dividing 1024x1024x1024. As a result it gives a number smaller than 8 (e.g. 7.7).

How can I get the size as 8 GB?

NOTE: I have used psutil, free, cat /proc/meminfo, vmstat but result did not change (I will get the terminal output and split it). I do not want to use any external program like dmidecode or lshw.

Python 3.8., OS: Debian-like Linux (x64), Kernel: 4.19
demirod
  • 81
  • 15
  • 2
    Does this answer your question? [Get total physical memory in Python](https://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python) – Glubs Mar 13 '21 at 07:32
  • It gives smaller than the actual ram size. I have already used psutil and explained it in the first post. – demirod Mar 13 '21 at 07:35
  • 1
    The BIOS hides parts of the physical RAM from the operating system for things like graphics memory. The operating system doesn't actually know the actual installed RAM size. The best you can do is round up, which isn't too hard. My system reports 0xF6488 KB, which rounds to 16 GB. – Tim Roberts Mar 13 '21 at 07:42
  • @Tim Roberts, it was in my mind to round up the number it I did not want to do that. In windows, OS it was using additional graphics memory from the RAM (about 1 GB). I checked it from dxdiag. Windows also show it as 8 GB but linux does not. There is also 1 GB graphics card memory (physical). I do not know if windows and linux use same amount of graphical memory from RAM or if it varies from OS to OS. Maybe there are another things that some RAM is stored/used for them and therefore it is not shown. – demirod Mar 13 '21 at 07:50
  • Confusion between gigabyte (GB) which is 10^9 bytes and gibibyte (GiB) which is 2^30 bytes? (7.7 GiB = 8.2 GB) – zigarn Mar 13 '21 at 07:50
  • There really is no solid answer without digging into the DSDT, which requires other modules. – Tim Roberts Mar 13 '21 at 07:57

1 Answers1

1

There is no way to get the information you want without digging into the BIOS information, which requires modules you don't have.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • I could not find any way to find the RAM value in the format I asked. There is no full solution offered for my question. I accepted your answer as answer. – demirod Mar 14 '21 at 03:54