Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Automatically reclaim memory from leaky programs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically reclaim memory from leaky programs
Authored by: wallybear on Apr 11, '12 06:06:27PM

And this is a bash one-liner that mimics the python script, using awk only:

vm_stat | awk '/Pages.(active|inactive|wired.down|free)/ { sub("Pages ","",$0) ; for (i=1;i<=NF;i++){sub(".",substr(toupper($i),1,1),$i)}; sub(":"," Memory:",$0) ; printf("%-20s %5.2d Mb\n", substr($0,1,index($0,":")), $NF*4/1024) }' ; sysctl -a | awk '/hw.memsize:/ {printf("%-20s %5.2d Mb\n", "Real Memory:", $2/1024/1024)}'

(not elegant, I agree, but it does the job)

[ Reply to This | # ]