fixed memory leak, added basic memory detection