Memory usage optimisation