Memory optimisation on arrays