Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The memory currently used for buffers and cache (as shown in the first line of the output from free) can be considered "almost free" memory, i.e., memory that could be immediately used to satisfy requests from a process for additional memory. The "cached" memory holds data that was recently read from or written to a block device and is kept around because (a) there is some chance that this data might be accessed again, and (b) keeping track of what is there costs almost nothing. The "buffers" memory is similar, but is used for file system metadata and data that is "in flight" to or from a block device, and the amount of memory allocated for that purpose is highly flexible.
So, the free command shows two calculations for "used" and "free" memory. In the first line, the amount shown for "buffers" and "cached" is included in the "used" total. In the second line, that memory is considered "free", i.e., subtracted from the previous "used" amount and added to the previous "free" amount.
I never seen swap area used in my system. allocated swap space 2047 mb free also 2047mb i.e. always showing used = 0
then purpose of swap area ...when linux utilize swap area ?
Swap indicates ram memory. If this area is not ever used , allocated ram memory is waste.
am i right ?
Last edited by thiyagusham; 11-16-2012 at 07:48 AM.
Swap is virtual memory. It is disk-storage that gets 'swapped' in and out of real memory by the kernel on an as-needed basis. Strategically, it is a last resort for allocation of memory, since it requires the relatively slow access to disk hardware. Showing that your system has never used swap memory means that your system has as much or more real memory than required for the applications you are using (a good thing).
--- rod.
Swap space is space on disk used as secondary storage when there is high demand for physical RAM. If you have plenty of RAM on your machine, it is normal to see little or no use of swap space, but if your system is running for a long time there will almost always be a few megabytes of memory pages that some process allocated when the machine was booted and never referenced since then, and those pages will eventually end up in swap.
The other time that swap space is used is if you use the "hibernate" (suspend to disk) feature of the OS. Then, all of the allocated non-cache pages of physical memory get saved in the swap space so that they can be reloaded when the machine is restarted. For that to work, you need swap space (which could be one or more partitions and/or files) that is at least as large as physical memory. If you're not using hibernate, then swap space of 1X to 2X physical memory (but not more than 2GB to 4GB) is a useful safety net for that time you're editing a couple of huge image files and need a lot more memory than usual. (A system that is actually using more swap than that would be so slowed by paging as to be almost useless, though there are undoubtedly some special use cases where huge amounts of swap make sense.)
If this area is not ever used , allocated ram memory is waste.
am i right ?
A 2GB swap space, that is never needed, is a good safety net for an ordinary Linux system. Just in case some process uses an unexpected large amount of ram, you will have just a slow down rather than a failure.
Yes, that 2GB of disk space is probably "wasted". How big is your hard drive? With an obsolete 80GB hard drive, I'd be a little upset about wasting 2GB. I have a fairly old 500GB hard drive, so wasting 2GB of it doesn't bother me at all. I have no clue what size hard drive you have, so I don't know whether wasting 2GB of it should bother you.
All the 1x ram or 2x ram nonsense frequently suggested was always an unsound "rule of thumb" to apply in cases where you have no clue how much swap you need. But really the amount of swap you might need has no real correlation with the amount of ram. Unless your hard drive is tiny, I think 2GB is a good swap size for an ordinary Linux system, regardless of ram size.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.