in reply to current RAM availability
Here's the fastest solution under linux. Note that sysinfo(2) says that since Linux 2.3.23 (i386), 2.3.48 (all architectures) the results are returned in $s[13] bytes units, not bytes. I, however, have Linux 2.4.25-gentoo here, and it returns the data in bytes so I assume that convention. In the following code, $t is the total memory, $f is the amount of free memory, not including swap or himem (which is the memory over 4G(?) on 32-bit systems).
sub __NR_sysinfo(){116} syscall(__NR_sysinfo, $s = pack("x256")) and d +ie $!; @s = unpack("l!L!9S!L!2I!", $s); ($t, $f) = @s[4, 5]; printf " +%.0fK used memory\n", ($t-$f)/1024;
|
|---|