Add function to profile memory