Why such horrible memory management?
Hello. I am not new to Linux I was using it as my primary OS for about 4 years, and although I already learned a lot, I still could not understand one thing. Why does Linux not free up memory? I know this is not a memory leak, because it happened every time I installed Linux (even on different distros), and it is not a hardware problem because it happens on all computers where I installed Linux throughout 3 years. For example, now I am using a computer with the following specifications: Intel P4 3.0Ghz, 1Gb RAM. I compiled my own Gentoo (newest). Why is it when I boot up into KDE, my mem usage is 175mb, and after using some programs - opera, konqueror, gaim, tuxracer, etc, i close them, but my memory usage stays at ~960mb! Why is this? I looked at the memory diagram in KDE, and it says memory is used for disk buffers? How do I free it up? Why doesnt it automatically go down after I am done using these applications? Is there a kernel patch or a daemon that can do this for me? I view my mem usage by the following applications: KDE information, top, cat /proc/meminfo, and a superkaramba applet. Please explain wat is going on and tell me how I fight this issue? cuz b4 i had 256mb and memory didnt go higher than 240mb, now i got 1 gig and it goes to 940.. so what if i get 4 gb will it be used at 3900mb? is there such thing as "enough" memory for linux or am i doing something wrong?? thank you.
|
Linux uses memory like that. Why would you want your memory wiped out if you closed one of those programs only to have to reload it back into memory when you want to use it again? It's faster and makes use of your memory. Why have all that memory if you're not going to use it? It's fine.
|
Linux-Powered is right. Just because it's not shown as free doesn't mean it isn't available. Try running a large KDE based app once and see how long it takes, then close it and open it again. It will load much faster the second time!
|
oh so ur saying that in real life it is free but only reserved? and so if i use an pplication the next time it will just use the reserved area of mem that shows up as used? ok maybe that is a good feature. thanks. but is there any way that I can see exactly how much of the mem is being used by apps at the moment (excluding the reserved memory)? Cuz the thing is, i used to think 256 or 512 megs is not enough for linux because it always showed it as used memory, so i bought 1 gig and i was surprised to see that it showed it as used up. so is 1 gig enough for linux? or should i buy more? thanks a lot for ur answers.
|
Quote:
|
Quote:
Quote:
Code:
free -m Quote:
|
Linux does this, and recent Windows versions do it, too: ever noticed that a program starts much faster the second time you run it in the space of a few minutes?
When a program finishes executing, and absent any other memory-pressures, Linux will happily be "lazy." Why rush to free-up memory when there's no demand to do so? Won't do any good, and may even be bad: maybe you'll want to use the same data again, soon. The odds are quite good... so why throw it away just to get it right back? Buffers are the lowest-priority use of memory... cacheing recently-used information in an area that is otherwise not being used. When new demands for memory arise, the buffers are among the first to go. Linux wants to keep all RAM full at all times, if it can. After all, "it's there, it's free, it's faster than anything else, so why not use it?" What you want to watch out for is swapping. It's fine for a certain amount of swap-space to be used, but when "swaps per second" starts going up and staying up, it's a sign of memory contention. |
Can you force it to clear the cache?
Just wondering. . . is there any way to FORCE it to clear the cache (ie any commands you can type or anything)? I left my computer on overnight, and I was surfing the Web last night after playing some DOOM 3 online. Today when I played it I noticed it was a lot choppier. I guess it's possible I was just really, really laggy but I don't think so. . . anyways, is there a way to clean this cache out?
|
Thanks for this thread
I learned a bit about what I have been observing on my own machines using Linux.
I have DamnSmall 1.4 on an IBM thinkpad with 24 MB of RAM! It has (and uses) a swap partition, but I can run Firefox and a bunch of other stuff all at once. It ain't exactly fast, but much more usable than it ever was with win95! Damn Small has that nice asmem tool, from afterstep, I think. It shows memory usage in different colors for programs and cache as well as swap usage. It looks a lot different on my Dell Inspiron 1100 with 512 MB (no swap). I have a bunch of stuff open and it says 85% available! WinXP really lags on this machine, but maybe that's 'cause it lacks hdparm! I am loving linux. I have a lot to learn and I thank you all for the discussion. Daniel |
There's no point trying to clear the disk cache - as soon as a program starts up memory is cleared from the disk cache and given to that program. Your problems are caused by something else or some other aspect of memory management.
|
There's a very informative article by Sapphirecat that does a nice job explaining how Linux memory management works, and why it appears that so much RAM is typically "in use" -- J.W.
|
Quote:
|
Quote:
|
Quote:
|
All times are GMT -5. The time now is 09:48 PM. |