changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/umem

changeset 7243: 34f64dcbbc25
parent: efddda59690a
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
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