valgrind is useful tool, good tutorial too!