#!/bin/bash
# Memory usage for 1 segment, 1 track point is reasonable

trap "/usr/bin/killall -q -u $USER ./Unit 2>/dev/null" 0 1 2 3 9 15
trap "/bin/rm -f $STDERR" 0 1 2 3 9 15
if [ ! -x ./Unit ]; then
  echo './Unit is missing or not executable'
  echo './Unit is missing or not executable' 1>&2
  exit 1
fi


$BIN/run -stderr=/dev/null /usr/bin/valgrind --tool=massif --massif-out-file=massif.out --log-file=valgrind.out ./Unit 12 1 1 < $WHERE/t021.in
grep "mem_heap_B" massif.out | cut -d'=' -f2 | $BIN/CheckMax "memory limit exceeded: " 16777216
