Ubuntu takes too much memory even if all processes killed
UbuntuThis forum is for the discussion of Ubuntu Linux.
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.
If i kill sshd, unload tulip, free memory remains almost the same.
So, almost no processes, nothing mounted, no kernel modules and still 145M of RAM in use! What could be using so much memory? AFAIK linux kernel should work on 32M (maybe even less) machine...
Well, what you thought of being memory usage is just actual usage by apps + buffers + cache. Buffers & cache are enlarged (as needed) when the memory gets free and shrinked when an app needs more memory than is available.
+/- buffers/cache line gives information with buffers & cache subtracted from full memory utilization, so it's what you actually need to estimate memory use by apps.
Memory management is a can of worms. In Linux it's exacerbated by the fact that (de-)allocation is lazy - it's only done when needed, or maybe in a "quiet time". It's too expensive to continually run the queues moving page frames around between free and allocated. Hence storage can appear (still) allocated even when the task has terminated.
Then there are the shared libraries ... and dentry and inode caches ... and things that aren't apparently accounted for anywhere.
There are a pile of sysctls for managing the points at which decisions can be affected - have a look at /proc/sys/vm/
I'd suggest you only play with such on a test system.
/proc/meminfo for overall system metrics - for specific tasks see /proc/<pid>/smaps
You want to run something it uses memory - you just don't (generally) get any say in what memory it uses.
Isn't RAM and CPU usage what makes Linux so much faster and smoother?
I'm not the most technically minded here, but in my own personal experience with several older versions of Windows on quite a few different PCs, it seemingly prefers the swap file over RAM; Whenever RAM dropped below 74% free, regardless of how much your system actually had, it really slowed to a crawl, as it had to access swap just to open a menu! And that's why Windows has always needed far more than the 'minimum requirement' to actually work, but CPU usage still hardly ever exceeded 19% as the system was still at the mercy of the HDD. Windows won't not swap. Ever.
I did try that once though, and it crashed. I had to hard-reset the PC and boot into 'safe' mode to re-enable swap. That was with Win98 on a PII w/128Mb RAM. It would work if you had a lot more, I suppose.
Just because a program/process is (or even all of them are) killed, does not mean the kernel will remove latent cached copies of blocks of disk data. If you restart one of these programs, it will start faster by virtue of not having to physically read those block of data from disk the first time. That's what cache is about.
If you want to see how much memory would be free, you could modify the startup scripts to display the sizes and pause. That way you can see before very much gets started. Or write/find a program that just allocates and uses up as much RAM as it can, which will eventually force cached data to go away. After that program runs a while, kill it, and then see how much is free (data a program allocates for itself will go away when the program process exits).
Well, it's seen that the memory is really used not for cache because when i start more and more programs, memory usage is increased, and when about 90% is shown as used, swap starts to be used instead of unallocation of cache.
Hmm... i restarted the machine and now it's using 33M without gdm... seems not very reproducible...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.