Added memory usage measuring code.