dynamic grid memory optimization