You are here

Free RAM determination?

5 posts / 0 new
Last post
w6bi
w6bi's picture
Free RAM determination?

I'm good with Linux, but can't figure this one out.

I have a Rocket M5 XW with Joe's alpha code in it.  It's reporting free memory as 39572 KB.

If I run free -m from its command line, I get:

root@WD6EBY-VC-SimiEast-5G:~# free -m
              total        used        free      shared  buff/cache   available
Mem:          60436       18520       27140        1088       14776       22532
Swap:             0           0           0


I know Linux can take advantage of buffered and cached RAM in addtion to free RAM, but I can't make the numbers come out right.

How does OpenWRT calculate free RAM space?

Thanks.

Orv W6BI
 

AE6XE
AE6XE's picture
Orv,   The code is doing the

Orv,   The code is doing the command "free" and then adding from the "Mem:" line (free + buffers).     Things in buffers can be freed up if the RAM is needed to start a program.  This buffer/cached data in RAM can be retrieved from (slower) flash when it is needed.  

I think it would be more informative to change this to "Available Memory".   This is the value in /proc/meminfo,  "MemAvailable".   This is the best (kernel) estimate of the memory that is available, to start a program.   When there's not enough RAM to start a program, the kernel has to select something to kill, Out-of_Memory condition.   I understand MemAvailable  includes more factors in the calculation than (free + buffers), thus more accurate.

Joe

w6bi
w6bi's picture
Works for me
[obeach@w6bi-house-pc ~]$ ssh -p 2222 root@wd6eby-vc-simieast-5g cat /proc/meminfo
MemTotal:          60436 kB
MemFree:           27712 kB
MemAvailable:      23112 kB
Buffers:            3672 kB


I'd vote for that.  Thanks, Joe.

Orv

AE6XE
AE6XE's picture
turning away from Available memory

I dug into the definition of Available memory.   This definition is focused on memory available before swapping pages to other storage, e.g. put to a disk drive and retrieve later when needed.   Since there is no swap on our embedded devices, the calculation is not going to be any better than what is currently used.

Available Memory:  removes the "low water mark" amount of RAM from the calculation, or a threshold defined where swapping would start occurring.     The value of Available Memory will actually show at time to be less than free memory.       

AREDN Free memory on status page:  (free + cache/buffer).   But cache/buffer includes things that can not be freed up, e.g. /tmp filesystem.   

I'd call Available memory the conservative number, and the (free + cache/buffer), the liberal number.   Both are wrong and the real answer is somewhere in the middle :)      I think an improved value would be  (free + cache/buffer - /tmp consumed).

Joe AE6XE

w6bi
w6bi's picture
Thanks

Just like everything else in Linux:  "It depends"  :-)

Thanks, Joe

Orv W6BI

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer