Optimized memory management