Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2019 11:59:00 +0200
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Eugene Grosbein <eugen@grosbein.net>, Garrett Wollman <wollman@bimajority.org>, freebsd-stable@freebsd.org
Subject:   Re: 11.2-STABLE kernel wired memory leak
Message-ID:  <0710bc0a-7691-b29f-3331-da94412ab737@FreeBSD.org>
In-Reply-To: <8a9361fd-4701-4e33-33f0-e4800af7637c@grosbein.net>
References:  <d8c7abc0-3ba1-40e4-22b1-1b30d28ced14@grosbein.net> <201902121757.x1CHve0h056876@hergotha.csail.mit.edu> <7125e053-5adf-929a-bde6-a64fceae2aaa@grosbein.net> <8a9361fd-4701-4e33-33f0-e4800af7637c@grosbein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12/02/2019 20:17, Eugene Grosbein wrote:
> 13.02.2019 1:14, Eugene Grosbein wrote:
> 
>> Use following command to see how much memory is wasted in your case:
>>
>> vmstat -z | awk -F, '{printf "%10s %s\n", $2*$5/1024/1024, $1}' | sort -k1,1 -rn | head
> 
> Oops, small correction:
> 
> vmstat -z | sed 's/:/,/' | awk -F, '{printf "%10s %s\n", $2*$5/1024/1024, $1}' | sort -k1,1 -rn | head

I have a much uglier but somewhat more informative "one-liner" for
post-processing vmstat -z output:

vmstat -z | tail +3 | awk -F '[:,] *' 'BEGIN { total=0; cache=0; used=0 } {u =
$2 * $4; c = $2 * $5; t = u + c; cache += c; used += u; total += t; name=$1;
gsub(" ", "_", name); print t, name, u, c} END { print total, "TOTAL", used,
cache } ' | sort -n | perl -a -p -e 'while (($j, $_) = each(@F)) { 1 while
s/^(-?\d+)(\d{3})/$1,$2/; print $_, " "} print "\n"' | column -t

This would be much nicer as a small python script.
Or, even, we could add a sort option for vmstat -z / -m.

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0710bc0a-7691-b29f-3331-da94412ab737>