move memory usage stuff to specific method