Re: [Nautilus-list] RAM size formula ?



On Thu, 2002-03-21 at 19:46, Glen Gray wrote:
> OK, currently using a KB reading from /proc/meminfo#MemTotal the code
> does the following to work out your RAM
> 
> (size_kb + 500) / 1000
> 
> Whats the recommended way (if any) to work out total ram on a linux box
> ?

No divide by 1024.

(proof: the first number from /proc/meminfo 
(in my case Mem:  525852672  (err, I thought 512M==536870912byte)
divided by 1024 corresponds to 
Memtotal:  (here 513528) and in megabyte this is 501M.

I do not know where the other 12 MB went to... 

So you should probably better use 
the size of the file /proc/kcore - 4096 because 

man proc says:

       kcore  This  file represents the physical memory of the system and is stored in
              the ELF core file format.  With this pseudo-file, and an unstripped ker­
              nel (/usr/src/linux/vmlinux) binary, GDB can be used to examine the cur­
              rent state of any kernel data structures.

              The total length of the file is the size of physical memory  (RAM)  plus
              4KB.

probably ((size of the file /proc/kcore - 4096 + 500) /1024 + 500)/1024

should to it.

Soeren.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]