Optimized memory allocation