Display Information About System RAM


free

Nowadays most computers come with hundreds of megabytes or even gigabytes of RAM, but it's still possible to find your machine slowing down due to a lot of memory usage or virtual memory swapping. To see the current state of your system's memory, use the free command.

$ free          total   used  free shared buffers cached Mem:   1036136 995852 40284      0   80816 332264 -/+ buffers/cache:   582772 453364 Swap: 1012084 495584 516500 


By default, free shows the results in kilobytes, the same as if you'd used the -k option. You can change that, however. The -b option shows you memory usage in bytes, and -m (which you should probably use most of the time) uses megabytes.

$ free -m                  total used free shared buffers cached Mem:         1011   963   48    0     78     316 -/+ buffers/cache:  569  442 Swap:         988   483  504 


From free's output, you can see that this machine has 1011MB of available physical RAM (actually 1024MB, but free displays it as 1011MB because the kernel takes up the remaining 13MB, so it could never be made available for other uses). The first line makes it appear that 963MB of that is in use, leaving only 48MB of RAM free. There's nearly a gigabyte of swap, or virtual memory, in place, too, and about half of that, or 483MB, has already been used. That's how it appears, anyway.

It's not that simple, however. The important row is the middle one, labeled -/+ buffers/cache. Hard drives use buffers and cache to speed up access, and if a program needs that memory, it can be quickly freed up for that program. From the point of view of the applications running on this Linux machine, 442MB of memory is free right now for use, with 569MB cached but available if needed. And that's in addition to the swap space you have available. Linux is nothing if not efficient when it comes to managing memory.

Tip

An excellent page with more information on free and Linux memory management can be found on the Gentoo Wiki, at http://gentoo-wiki.com/FAQ_Linux_Memory_Management. Even though it's purportedly for Gentoo (a unique Linux distribution), it still applies to all versions of Linux.




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net