add memory usage function