Added automatic memory usage tracking