RPi Pico 上的 GC 是否损坏

Is GC Broken on RPi Pico

我使用的是 micropython 的最新稳定版本,下面是我的整个程序。

import gc
gc.collect()
print('free:{}, alloc:{}'.format(gc.mem_free(), gc.mem_alloc()))
#free:187488, alloc:4576

我的 64k RAM 去哪儿了?我知道这不是硬件问题。我插入了一个全新的 Pico,它甚至没有焊接接头,并得到了完全相同的结果。我错过了什么吗?

编辑:

我在 ports/rp2/main.c 中找到了以下内容。为什么不是 256

static char gc_heap[192 * 1024];

似乎自动分配了 64kb 的 RAM 以适应 firmware.elf。因此,您不仅实际上没有获得 264k 的 RAM(由于 Hypervisor 使用 8k),而且您也没有获得 256k 的 RAM。将我的问题中的编辑更改为:

static char gc_heap[256 * 1024];

导致这些消息:

firmware.elf section '.bss' will not fit in region 'RAM' 
region 'RAM' overflowed by 40848 bytes

结论:在使用 micropython 的 Raspberry Pi Pico 上只有 192kb 的可用 RAM。