This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/tool/leak-check.sh

36 lines
586 B
Bash
Raw Normal View History

#!/bin/sh
# This script works only with memory-trace file generated in Linux.
file="memory-trace"
if [ ! -f $file ]; then
echo no memory trace file found
exit 1
fi
declare -A addrs
while read line; do
IFS=" " read -r type addr1 trash1 addr2 trash2 <<< $line
case "$type" in
"new")
addrs[$addr1]="allocated"
;;
"resize")
addrs[$addr1]="freed"
addrs[$addr2]="allocated"
;;
"delete")
addrs[$addr1]="freed"
;;
*) ;;
esac
done < $file
for addr in "${!addrs[@]}"; do
if [ "${addrs[$addr]}" == "allocated" ]; then
echo $addr
fi
done