Adding a function for computing memory usage