Vladimir A. Pavlov wrote: > On Friday 29 September 2006 21:37, Luca wrote: > >> So my question is simple, is it normal that linux uses all the ram >> memory and not swap partition? >> (Think I should order another 1G DDR memory card...) >> > > Yes, it is. > > In addition to the usual use of RAM for storing there programs being > executed and the memory they allocate with malloc, realloc, etc, Linux > also stores there a disk cache. > > When a program accesses the disk the kernel a) reads the data required > from the disk, b) stores it in the memory. When another (or the same) > process requests the same data Linux reads it from the memory rather > than the disk, that greatly decreses the data access time. This "disk" > data in memory is called "disk cache". > > But when no more memory (ram) is available the kernel can decide > between the two actions to do. 1) begin to use the swap, 2) flush the > disk cache to the disk and use the "freed" memory. Since the disk cache > has anyway to be written to the disk (since the cache is "transparent" > for programs, they don't know about it, thinking the data they write to > the disk actually goes to the disk) the kernel selects the latter case. > > As you can see, if using the technique described ram will be ~100% full > almost all the time (because the kernel uses the memory not allocated > for any process as the disk cache). > > Swap is used only when there is no enough "actually free" memory. For > example, if some of your programs tries to eat all the memory in the > system then at some point the kernel will begin using swap. > > So, you will have to order another memory card if either you swap is > often used or you want to increase the performance of your system by > increasing the disk cache size. But note that in the latter case you > will still see that the memory is ~100% full while the swap is 100% > free. > > P.S. If you wonder, I have 512M RAM on my desktop, 503M being used. > When I lanch the program "freeing" the disk cache memory, only > 160M is actually used when I'm in KDE, and only 30M is used when I > am in console with apache 2.0 in use. > > Also note that I don't use the swap at all since 512M is really > sufficient for me. > > Thanks for the clarification Vladimir, when I had 512M ram LFS and other distros I had installed on various hds used ram and swap partition too. Right now I have just brought power on the pc and taking a look at the infos showed up that actually there are 460M free physical memory and now after passing 'ldconfig' there are 259M. Today I expect a 320G hd so for the eventually new 1G ram I will expect some time...
Bye, Luca -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
