mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-04 12:51:41 +00:00
* add memusg to pal_loader script * Stop bleeding PAL handles. Deprecating DkOjectReference and reference counting in PAL handle. Deprecating DkSemaphoreDestroy and DkEventDestroy (replaced by DkObjectClose). Cleaning unused PAL handles in the library OS. Adding a heap tracing feature to profile usage of PAL handles. * fix a bug in SGX mode that mapping untrusted files into memory never got free by DkVirtualMemoryFree() * adding lighttpd SSL option * fixing the freeing convention of PAL handles; On SGX, event and mutex handles need to be freed seperately. * changing how mutexes and events are allocated on SGX * fixing GCC regression tests (for both Linux and SGX) * fix a double-free problem of the first thread handle
54 lines
1.2 KiB
Bash
Executable File
54 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# memusg -- Measure memory usage of processes
|
|
# Usage: memusg COMMAND [ARGS]...
|
|
#
|
|
# Author: Jaeho Shin <netj@sparcs.org>
|
|
# Created: 2010-08-16
|
|
set -um
|
|
|
|
# check input
|
|
[ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; }
|
|
|
|
# TODO support more options: peak, footprint, sampling rate, etc.
|
|
|
|
pgid=`ps -o pgid= $$`
|
|
|
|
command="$@"
|
|
|
|
# make sure we're in a separate process group
|
|
if [ $pgid = $(ps -o pgid= $(ps -o ppid= $$)) ]; then
|
|
cmd=
|
|
set -- "$0" "$@"
|
|
for a; do cmd+="'${a//"'"/"'\\''"}' "; done
|
|
exec bash -i -c "$cmd"
|
|
fi
|
|
|
|
# detect operating system and prepare measurement
|
|
case `uname` in
|
|
Darwin|*BSD) sizes() { /bin/ps -o rss= -g $1; } ;;
|
|
Linux) sizes() { /bin/ps -o rss= -$1; } ;;
|
|
*) echo "`uname`: unsupported operating system" >&2; exit 2 ;;
|
|
esac
|
|
|
|
rm -f "histogram.mem.usg"
|
|
|
|
# monitor the memory usage in the background.
|
|
(
|
|
peak=0
|
|
while sizes=`sizes $pgid`
|
|
do
|
|
set -- $sizes
|
|
sample=$((${@/#/+}))
|
|
echo "$sample" >> "histogram.mem.usg"
|
|
let peak="sample > peak ? sample : peak"
|
|
sleep 0.1
|
|
done
|
|
echo "memusg \`$command\`: peak=$peak kiloBytes" >> "peak.mem.usg"
|
|
) &
|
|
monpid=$!
|
|
|
|
echo "running: exec $@"
|
|
|
|
# run the given command
|
|
exec "$@"
|