D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Out of memory )-:

 

On 06/09/13 11:27, Gordon Henderson wrote:
>
> Well, not quite, but what's it doing!!!
>
> top - 11:19:05 up 6 days, 14:36,  2 users,  load average: 0.08, 0.26,
> 0.22
> Tasks: 175 total,   2 running, 171 sleeping,   2 stopped,   0 zombie
> %Cpu(s):  2.3 us,  2.7 sy,  0.1 ni, 95.0 id,  0.0 wa,  0.0 hi,  0.0
> si,  0.0 st
> KiB Mem:   3831912 total,  3509196 used,   322716 free,   271272 buffers
> KiB Swap:        0 total,        0 used,        0 free,   890016 cached
>
>   PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
> 13071 gordon    20   0 1898m 1.3g  14m S   6.7 35.5 414:59.27 gnome-shell
>  5369 gordon    20   0 1018m 393m  23m S   6.3 10.5 209:48.38 firefox
> 30282 gordon    20   0  570m 356m  17m S   0.0  9.5   2:20.91 Fritzing
> 25137 gordon    20   0  247m  30m 6240 S   0.0  0.8   2:11.95 soffice.bin
>  3489 root      20   0 97756  27m  14m S   1.0  0.7 104:51.99 Xorg
>  4011 gordon    20   0  298m  20m 5328 R   1.0  0.6  18:42.48 xchat
>
> So much bloat - all for some nice eye-candy )-: 1.8GB of RAM used for
> what?
>
> Gordon
>

Just as Tom said, it's Linux doing it's job properly - the modern
kernel(s) cache pretty aggressively when you have free RAM, and why not?
Unlike arbitrarily smashing the wear levelling on your SSD by swapping
to it constantly, there's nothing to be gained by *not* utiltising all
that lovely free RAM in your machine. Even so, it tends to cut off at a
certain, pretty predictable level - this machine is pretty much "at
rest" just running my usual stuff - a terminal or two, firefox &
thunderbird, a couple of file browser windows, etc and of course
gnome-shell. This is before I fire up KVM/VMWare/VBox, start compiling
or doing anything heavy, so at the moment my system is doing pretty much
what yours is doing.

However, this machine has 16Gb of RAM instead of your 4Gb, and even so,
it's memory usage is very similar:

top - 15:23:52 up 104 min,  2 users,  load average: 0.14, 0.33, 0.26
Tasks: 261 total,   2 running, 259 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.7 us,  0.4 sy,  0.1 ni, 93.2 id,  0.1 wa,  0.3 hi,  0.2 si, 
0.0 st
KiB Mem:  16403432 total,  4761536 used, 11641896 free,   196504 buffers
KiB Swap:      0 total,        0 used,    0 free,  2708928 cached

In my experience, until I start doing seriously computationally
expensive work, no matter how long I leave this machine running memory
usage never really increases past this point - it doesn't ever just keep
bloating and run out (I mean, that would be an absolute disgrace in a
2013-era modern sophisticated OS). My i7 has 32Gb of RAM and runs an
almost identical setup, except with the Awesome WM instead of Gnome3 and
"at rest", it's memory stats are almost identical: in fact, slightly
lower. The kernel on the i7 doesn't go mad and just suck up all
available RAM for caching, it stays pretty constantly at 1-2Gb until I
start pushing it. Like pretty much all systems.

I've seen this so many times over the last few years as relatively
speaking crazy-fast hardware has crept down in price and become
mainstream - 15 years ago who would have thought we'd have affordable
quad/hex core CPUs and 16-32Gb of RAM in our sub-£1k PCs? Yet people
constantly complain that *shock!* *horror!* their sophisticated OS
actually utilises all that power intelligently. For some reason
otherwise very technical Linux users/admins seem offended that 25% of
their available RAM is properly utilised by their OS for caching stuff:
why? For those who may not know, Windows and Mac OS both do this as well
(Win7/8 are both *very* aggressive at caching). Funnily enough, if you
then start a "make -j8" in /usr/src/linux whilst watching htop you can
see in realtime as your OS, which isn't stupid, immediately tosses all
your cached soffice/firefox/etc crap straight out the window and
immediately re-prioritises it's memory allocation.

In short: this is modern Linux on modern hardware, behaving exactly as
it should. What's the point in having a powerful system that never uses
it's available resources? It's only memory bloat when it's
inefficient/incorrect and your system actually runs out of physical RAM
and starts paging - that sucks. But I bet it never happens on your
machine, even if you leave firefox/gnome-shell running for weeks on end.
Unless you've made some kind of manual "correction" and ruined it, of
course...

For those that are that worried about it, fear not! This is linux after
all, so you can always roll up your sleeves and start screwing about
with different schedulers, setting the tunable virtual memory parameters
through /proc/sys/vm and recompiling your kernel with different
parameters but speaking as someone who actually has to do this
(primarily configuring *much* bigger boxes running stuff like Oracle 11G
or in-memory DBs which have very, very specific parameters to adhere to)
I can honestly tell you that for a general purpose home PC without
multiple CPU sockets, >128Gb RAM and costly SLAs to maintain you would
have to be literally out of your mind to even bother trying.

TL:DR - you're worrying about nothing. Sit back, relax, and have some
faith in the Linux gurus. If not the half-arsed distro weenies, at least
people like Torvalds, who I think can be generally trusted not to
randomly introduce completely mad memory eating tendencies into the
mainline kernel. Sure, you have to keep an eye on those Gnome-shell
coders who are a bit, umm, erratic, and the firefox plugin-container
(thanks to stupid Flash) can sometimes runaway with itself a little, but
that's it.

Keep calm and carry on caching!

Regards

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq