Large programs on Pico Explorer - Display problem

I’ve just been working on a 300 line MicroPython graphics program and have been getting disturbance along the bottom edge of the screen and at times Thonny has lost connection with my Window 10 PC and the Pico - COM 3 error and loads of red warnings in the REPL window.

On re-powering the Pico and pressing STOP icon on Thonny I was able to re-run the program a few times before it happened again.

I fear that the garbage collect routines are not working very well so I added
import gc
print(gc.mem_free())
near the top of the program, under the boilerplate, and got just 668 as the answer.

I’m obviously near the limit!

Probably worth checking if you get similar problems.

I was getting the exact same thing - corruption at the bottom of the display and loss of serial connection. I had to slow my draw updates and also break out of the draw code with a button press. Even then I would frequently lose connection. I have not seen the display corruption since I switched to C++ but now I have to disconnect and reconnect every time I change the program but at least it is consistent. In my case the program was still quite small but it was pushing the processor quite a bit.