Messages in this thread | | | Date | Fri, 22 Jan 1999 14:11:09 -0500 | From | "David D.W. Downey" <> | Subject | Libs in memory response. |
| |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Since I have had NUMEROUS requests for copies of the answer to my original question about libs not dropping out of memory, I am going to repost my question and the answers I recieved. Also, couriously, it seems that i am NOT the only one who has this "feature" problem ect ect.
For the flamers of the original question... Dang, must be ALOT of us idiots out here on this list. (Sorry, couldn't resist the dig. hehehe)
ORIGINAL QUESTION - ==============================
Evening all. My question is, what is the kernel's time limit for dropping unused libs from memory? Same thing for the modules. Not sure exactly what is responsible for it but here is the problem. When I boot I only use about 17MB of RAM with everything I need loaded. OK, all well and good, so what's the problem you might ask.
Easy, when I load X11, memory usage increases to around 93MB. OK, not a problem. The kernel will drop the libs out of memory when all calling apps have not accessed them in memory for (I believe) 60 seconds, starting with the oldest lib first.
Wait a minute! It's 3 hours later and I have been out of X11 mode for the last 2 1/2 hours! Why is my memory usage still being reported as 93MB? Well, I look and I see that over 48MB of it is cached.
OK, so first question is, how do I change the flush times on system cache? I have played with bdflush (Running RH 5.2) and with sync. Nothing. Second question, how do I change the system's memory purge time so I can clean some of these stale libs out of memory? Third and last question, if the kernel itself is not responsible for this type of memory maintenance, what is?
JIM NANCE'S ANSWER - ======================
Hi David,
> Evening all. My question is, what is the kernel's time limit for > dropping unused libs from memory? Same thing for the modules. Not sure > exactly what is responsible for it but here is the problem.
There is not a time limit. It will drop the least recently used pages (4 K blocks) from memory when something else needs the memory.
> Wait a minute! It's 3 hours later and I have been out of X11 mode for > the last 2 1/2 hours! Why is my memory usage still being reported as > 93MB? Well, I look and I see that over 48MB of it is cached.
Yes, this is the way its supposed to be.
> OK, so first question is, how do I change the flush times on system > cache? I have played with bdflush (Running RH 5.2) and with sync. > Nothing. Second question, how do I change the system's memory purge > time so I can clean some of these stale libs out of memory? Third and > last question, if the kernel itself is not responsible for this type > of memory maintenance, what is?
The cache is only flushed when something else needs the memory. Is this causing you problems? You can force the cache to get dumped by loading something else into memory, but I am not sure why you would want to.
Jim
GREGORY MAXWELL'S ANSWER - ============================
That's not libs eating your memory. It's read cache.
Linux works by the theorey that free memory is wasted memory, so it uses almost all your unused ram for disk cache. This is normal and good. It takes almost NO time to deallocate this cache memory.
Here is the output of free on one of my servers. The number 96828 is the number you want to look at. That means I have about 96MB avail to apps.
total used free shared buffers cached Mem: 128040 123932 4108 57012 59668 33052 - -/+ buffers/cache: 31212 96828 Swap: 216768 4 216764
ONE OF THE NICER OF THE LESS TOLRANT - NAME WITHHELD BY ME ==============================================================
(off-list)
You obviously have little idea how memory works under a modern operating system.
David D.W. Downey wrote: > Evening all. My question is, what is the kernel's time limit for > dropping unused libs from memory?
The kernel doesn't interface with "libraries" at all.
> Same thing for the modules.
Depends on the distribution. I believe a cron job cleans them out or something. I don't use modules myself, so I won't comment further.
> Not sure > exactly what is responsible for it but here is the problem. > > When I boot I only use about 17MB of RAM with everything I need > loaded. OK, all well and good, so what's the problem you might ask. > > Easy, when I load X11, memory usage increases to around 93MB. OK, not > a problem. The kernel will drop the libs out of memory when all > calling apps have not accessed them in memory for (I believe) 60 > seconds, starting with the oldest lib first. > > Wait a minute! It's 3 hours later and I have been out of X11 mode for > the last 2 1/2 hours! Why is my memory usage still being reported as > 93MB? Well, I look and I see that over 48MB of it is cached.
Yes, the libraries (and the binaries themselves, and their data) will stay mapped forever, until something else needs the ram (be it another app or disk cache - the kernel automatically sizes the cache based on how much you need and how much RAM you have). There's no reason to purge it ahead of time - you don't get extra bonus points in heaven for using as little RAM as possible. The kernel tries to use _all_ of your RAM to the best extent it can. The only reason it leaves any free at all is so it can respond to demand for new memory at very low-latency. If you have plenty of spare RAM, this means that a lot of rarely stuff is probably still cached. Once you need more RAM, the kernel will start reaping these unused parts, and your cache will shrink.
If you consider this a problem, I'd suggest using an operating system that doesn't dynamically grow its cache, such as Windows 3.1. This will leave your unneeded RAM completely unused which you seem to perversely desire.
=======================================================================
There were other email responses, but these seemed to cover the original question better than the rest.
Hope the info here helps out.
David D.W. Downey A.K.A PGPKeys
-----BEGIN PGP SIGNATURE----- Version: PGPfreeware 5.5.3i for non-commercial use <http://www.pgpi.com>
iQA/AwUBNqjNTH1oPthwuh4KEQLjmQCfbQOayWK34NBkSEokPfB/lvgPFE4AmwUR gXLyXPIO6Xpg8YPVIJu/DHb7 =70uY -----END PGP SIGNATURE-----
David D.W. Downey A.K.A PGPKeys Designer/member Freespace Developers List Web Site - http://www.descent-freespace.com Listserv - fdl@warpcore.org
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |