Update memory at the start of every frame, or synchronously mid-frame when a framebuffer is set twice as render target; code cleanup.