function counting script, memcheck.sh