Grid memory optimization