Optimised memory allocation