On Thu, Feb 05, 2004 at 12:40:58AM +0800, Peter Santiago wrote: > > In short: it is not a bad thing. Linux sees free memory, and rather than > > wasting idle resources uses it as disk cache and for buffers. So while the > > memory is being used, it is not /in use/ as far as your interpretation of > > the above. It will be released to applications if/when you need it at a > > moment's notice. > I think I get the picture. Please correct me if I'm wrong. > If Fedora ever touches the swap file, once it has allocated the requisite > amount of it, and finished using it, the OS will not imeediately > deallocate the swapfile but rather it would lie in wait till there's > another process that will be needing it. Correction: The swap file/parition is accounted for separately. The swap file/partition only exists on disk. The 'free' command tells you how much memory is used separately from how much swap is used. Whenever an application allocates memory, or whenever a disk block is read from disk, it gets stored to free memory (RAM). Under optimum conditions, free memory (RAM) is always available, and Linux never deallocates memory. The benefit, in this case, is that if you access the contents for a file once, and then access the contents for a file a second time an hour later, Linux may not require a (slow) disk access. The file contents are already in memory. Under normal conditions, though, the amount of data cached to memory is more than the amount of memory. In this case, when Linux needs a block of memory, it will decide which other block of memory it doesn't need. If it chooses to get rid of a block of memory that was only ever read (such as file contents), the block is just marked as free, with no overhead. If it chooses to get rid of a block of memory that was written too, the block will be written to the proper section of disk, or to the swap file/partition. If that block is then read again later, it must be re-read from disk or the swap file/partition. > So I don't really need to worry > about the condition. The only time I'll get worried is when disk swapping > happens often, indicating that real memory is not enough. It is actually good for the swap file to get used. Applications that are infrequently, or never accessed, don't really need to be taking up memory. They can be safely stored stashed in the swap file/partition. This leaves your memory open to be used for caching directory structures, and file contents. If you ever do a 'grep' over a large collections of files and/or directories, you will very easily notice the difference when the contents are cached in memory vs when they need to be accessed from disk. What you want to make sure of, is that blocks are not being read/written to the swap file/partition with such a regularity that system performance suffers. If this ever happens, buy more RAM, or figure out which applications you are running that you do not need, and keep them from starting. Cheers, mark -- mark@xxxxxxxxx/markm@xxxxxx/markm@xxxxxxxxxxxxxxxxxx __________________________ . . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder |\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | | | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them... http://mark.mielke.cc/