On Sat, Jun 21, 2003 at 10:50:52AM +0200, Thomas Hertweck wrote:
Wenn Du nun noch kurz erlaeutern koenntest, wie das nun mit den Ausgaben von "top" und dort insbesondere den Spalten VIRT, RES, und SHR in Einklang zu bekommen ist, dann waere ich gluecklich.
Du meinst wie nachstehend? Oder was willst Du genau vorgerechnet haben? Kristian $ cat /proc/1/status Name: init State: S (sleeping) Tgid: 1 Pid: 1 PPid: 0 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 32 Groups: VmSize: 448 kB VmLck: 0 kB VmRSS: 76 kB VmData: 24 kB VmStk: 4 kB VmExe: 408 kB VmLib: 0 kB SigPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: ffffffffd770d8fc SigCgt: 00000000288b2603 CapInh: 0000000000000000 CapPrm: 00000000ffffffff CapEff: 00000000fffffeff $ ./memuse.pl 1 init 417792 s 08048000-080ae000 r-xp 00000000 03:03 163894 /sbin/init 12288 080ae000-080b1000 rw-p 00066000 03:03 163894 /sbin/init 24576 080b1000-080b7000 rwxp 00000000 00:00 0 4096 bffff000-c0000000 rwxp 00000000 00:00 0 share = 417792 ( 408.00 KB) private = 40960 ( 40.00 KB) total = 458752 ( 448.00 KB) ( 91.07 % shareable) $ cat ./memuse.pl #! /usr/bin/perl -- # Kristian Köhntopp <7elhq3$ocs@valiant.koehntopp.de> die "Usage: $0 PID\n" unless $ARGV[0] > 0; $file = sprintf "/proc/%s/cmdline", $ARGV[0]; open IN, "<$file" or die; ($line = <IN>) =~ s/\0//g; close IN; print "$line\n";; $file = sprintf "/proc/%s/maps", $ARGV[0]; open IN, "<$file" or die; while(<IN>) { ( $mem, $prot, $offset, $dev, $inode) = split; ( $start, $stop ) = split "-", $mem; $size = hex($stop) - hex($start); $total += $size; $able = " "; if ($prot =~ /^r-/ and $inode != 0) { $share += $size; $able = "s"; } printf "%12d %s %s", $size, $able, $_; } close IN; printf "share = %12d (%8.2f KB)\n", $share, $share/1024; printf "private = %12d (%8.2f KB)\n", $total-$share, ($total-$share)/1024; printf "total = %12d (%8.2f KB) (%8.2f %% shareable)\n", $total, $total/1024, $share/$total*100;