Scratchbook

Das Leben ist immer anders als die Realität.

„Free Memory“ unter Linux

Claude, 3. Mai 2012, 16:58 Uhr

Warning: Use of undefined constant ri_rand_compare - assumed 'ri_rand_compare' (this will throw an Error in a future version of PHP) in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/random-image-widget/random_image.php on line 129 Warning: Use of undefined constant ri_rand_compare - assumed 'ri_rand_compare' (this will throw an Error in a future version of PHP) in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/random-image-widget/random_image.php on line 130 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 700 Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 707 Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 700 Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 707

Alle Unix-Tools, welche die Speicherplatzsituation (RAM) des Systems ausweisen, zeigen nach einer gewissen Laufzeit beim freien Speicher nur noch Bruchteile des gesamten verfügbaren Speichers an – auch wenn die laufenden Prozesse in Wirklichkeit gar nicht so viel Speicher benötigen und eigentlich viel mehr freier Speicher vorhanden ist.

Warum ist das so?

Linux hält alle Daten, die es mal von der Festplatte gelesen hat, im RAM auf Abruf bereit. Diese Daten – genannt «disk cache» – sind eigentlich freier Speicher, welcher freigegeben wird, sobald ein Programm ihn benötigt.

Leider verfälscht das die Anzeige des gesamthaft freien Speichers unter Linux.

(Quelle: http://www.linuxhowtos.org/System/Linux%20Memory%20Management.htm)


Das Java-Geschwür gibt sich wie immer allergrösste Mühe, alle verfügbaren Systemressourcen für sich zu beanspruchen. Aber sein Speicher wurde auf 4 GB limitiert. Trotzdem zeigt top an, dass von den 12 GB Memory nur noch etwa 400 MB frei sind.

Abhilfe

Alle aktiven Prozesse auflisten, und deren effektiven Speicherverbrauch zusammenzählen.

Das Kommando ps auxc listet alle aktiven Prozesse auf. Darunter auch die Spalte RSS – Resident set size, the non-swapped physical memory that a task has used (in Kilobytes)

$ ps auxc

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  10352   632 ?        Ss   Apr10   0:02 init
root      3425  0.0  0.0   5912   668 ?        Ss   Apr10   0:02 syslogd
root      3428  0.0  0.0   3808   432 ?        Ss   Apr10   0:00 klogd
root      3446  0.0  0.0  98764  3316 ?        S    Apr10   0:00 pbx_exchange
blubber   3449  0.0  0.0 176132  7276 ?        S    15:51   0:00 httpd
dbus      3462  0.0  0.0  21260   704 ?        Ss   Apr10   0:00 dbus-daemon
blubber   3468  0.0  0.0 176180  7276 ?        S    15:51   0:00 httpd
root      3480  0.0  0.1 174992 12596 ?        Sl   Apr10   3:41 snmpd
blubber   3482  0.0  0.0 176180  7816 ?        S    15:51   0:00 httpd
root      3499  0.0  0.0  63520  1220 ?        Ss   Apr10   0:00 sshd
root      3518  0.0  0.0  21648   892 ?        Ss   Apr10   0:00 xinetd
ntp       3534  0.0  0.0  19196  4892 ?        SLs  Apr10   0:00 ntpd

 

Skriptibus. Effektiv belegter Speicher berechnen. „Renn durch alle Werte der 6. Spalte (RSS), addiere und gib aus“:

$ ps aux | awk '{sum +=$6}; END {print sum}'
5348340

free zeigt die Speichersituation an. Unter anderem auch total Memory.

$ free

             total       used       free     shared    buffers     cached
Mem:      12296040   12229320      66720          0     839756    5974144
-/+ buffers/cache:    5415420    6880620
Swap:     14683400        308   14683092

 

„Zweite Zeile, zweiter Wert von ‚free‘ ausgeben“:

$ free | sed -ne '2p' | awk '{ print $2 }'
12296040

Und jetzt alle zusammen: Gesamter Speicher – effektiv belegter Speicher = freier Speicher

$ echo $((`free | sed -ne '2p' | awk '{ print $2 }'` - `ps aux | awk '{sum +=$6}; END {print sum}'`))
6848232

hanna

Entschuldige bitte meine Anfängerhaftigkeit, ich bin
kein Linuxer:

Das PS -Kommando, ist das resident im Kernel vorhanden,
oder wird es nachgeladen, wie es z.B. under dos üblich war?D
Das Programm „blubber“, was macht es in Deinem Rechner genau? 😉

hanna.
..

Claude

«ps» ist einfach ein programm, so wie free, sed und awk auch. es zeigt die aktuell laufenden prozesse an.

ps — process status
http://ss64.com/bash/ps.html

und blubber ist ein benutzername (das programm wird unter diesem benutzer ausgeführt…) 😉

hanna

> ps — process status
schon klar, das Teil residiert nirgendwo und liesst auch nicht den Speicher aus,
sondern eine Datei, die vom Kernel angelegt wurde, oder?

> und blubber ist ein benutzername
ein Benutzername, schau’an. 😉 ist das jetzt ein Programm unter „Blubber“ oder mehere?

ich werde mal ’n Rechner für Linux freimachen, soviel Bildungslücken sind
schoflich … 😉
Was würdest Du für jemanden empfehlen, der zwar embedded
Systeme kennt und Windows, etwa Ubuntu oder doch Suse?

Naja, ich bin von CP/M über DOS nach Windows gekommen …

danke!
..

Claude

ein benutzername, genau 🙂 es werden halt mehrere programme als benutzer „blubber“ ausgeführt (in diesem fall httpd)

ubuntu suckt seit geraumer zeit, suse suckte schon immer xD
aber. wenn du linux so richtig kennenlernen willst, führt kein weg an gentoo vorbei. http://www.gentoo.org/ – mit hilfe des gentoo-handbuchs (http://www.gentoo.org/doc/de/handbook/handbook-x86.xml?part=1&chap=1) hab ich es aufgesetzt und so viel über linux gelernt wie noch nie. hier wird alles erklärt. by design werden programme grundsätzlich immer kompiliert. das kann so einige zeit in anspruch nehmen.

wenn du lieber was möchtest, wo du schneller (vorkompilierte) programme installieren kannst, dann kann ich debian empfehlen.

Claude

ich bin grad am schwärmen.

http://www.gentoo.org/doc/de/handbook/handbook-x86.xml?part=1&chap=3

Wenn alles obige fehlschlägt, müssen Sie Ihr Netzwerk manuell einrichten. Dies ist überhaupt nicht schwierig. […] Nachdem Sie dies gelesen haben, werden Sie wissen, was ein Gateway ist, wozu eine Netzmaske dient, wie eine Broadcast-Adresse aufgebaut ist und warum Sie Nameserver benötigen.

..es folgt eine einführung in IP und netzwerke. das ist eben gentoo. über den hag schauen und alles verständlich erklären – ich liebe es!

hanna

@Claude, nicht schlecht, gar nicht schlecht!
Ich werds am Wochenende mir mal ansehen …

Hilfst du mir dann, wenn’s klemmt?

..

Claude

🙂 Aber natürlich!

Warning: count(): Parameter must be an array or an object that implements Countable in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/themes/scratchbook/navigation_bar_bottom.php on line 1