Memory usage optimization