import gc
import uos
from flashbdev import bdev

try:
    if bdev:
        vfs = uos.VfsFat(bdev, "")
except OSError:
    import inisetup
    vfs = inisetup.setup()

gc.collect()

@@ -3,16 +3,68 @@
 port gc%0A
+gc.threshold((gc.mem_free() + gc.mem_alloc()) // 2)%0A
 import u

Set GC alloc threshold to half of heap size.