Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!uunet!europa.asd.contel.com!gatech!hubcap!ncrcae!ncr-sd!serene!rfarris From: rfarris@rfengr.com (Rick Farris) Newsgroups: comp.unix.xenix.sco Subject: Re: How do you find the amount of RAM free? Message-ID: <1991Jun13.011554.2840@rfengr.com> Date: 13 Jun 91 01:15:54 GMT Article-I.D.: rfengr.1991Jun13.011554.2840 References: <1265@teslab.lab.OZ> Organization: RF Engineering, Del Mar, California Lines: 42 In article <1265@teslab.lab.OZ> andrew@teslab.lab.oz.au (Andrew Phillips) writes: > It would also be nice if we could tell at any time how > much RAM is unused. Here's a short perl script that shows how much memory is used and how much is available. I didn't write it, any kudos should go to Rock Kent; rock@rancho.uucp. --- #!/usr/local/bin/perl eval "exec /usr/local/bin/perl -S $0 $*" if $running_under_some_shell; open(PS, "ps -el |"); while () { $tot += substr($_, 48, 6); } close(PS); open(SAR, "sar -r 1 |"); while () { $tot2 = substr($_, 9, 7); } close(SAR); printf "\nUsed : %4.2f mb\n", $tot / 1024; printf "Avail: %4.2f mb\n", ($tot2 * 4096) / 1024000; --- Output of above program: serene:/u/rfarris> pmem Used : 4.64 mb Avail: 6.24 mb -- Rick Farris RF Engineering POB M Del Mar, CA 92014 voice (619) 259-6793 rfarris@rfengr.com ...!ucsd!serene!rfarris serenity bbs 259-7757