added memory tracking functionality