]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/umem
cat: remove stupid long cast
[plan9front.git] / rc / bin / umem
1 #!/bin/rc
2 # umem pid [binary] - print summary of allocate blocks in a running process
3 rfork e
4 if(! ~ $#* 1 2){
5         echo 'usage: umem pid [binary]' >[1=2]
6         exit usage
7 }
8
9 p=$1
10 binary=()
11 if(~ $#* 2)
12         binary=$2
13
14 echo 'blocksummary()' | acid -lpool -lleak $p $binary | awk '
15         $1 == "block" {
16                 addr=$6
17                 size=$3
18                 alloc=$4
19                 total[alloc] += size
20                 count[alloc]++
21         }
22         $1 == "summary" { 
23                 alloc=$2
24                 cnt=$3
25                 size=$4
26                 total[alloc] += size
27                 count[alloc] += cnt
28         }
29         END{
30                 for(i in count)
31                         printf("%6d %11d %s\n", count[i], total[i], i);
32         }
33 ' | sort -nr