That to me points to compilation and code generation of 'main.py' pushing things to the limit, over the limit having reserved 32KB.I tried reserving it in boot.py but now something very strange seems to be happening. My program does not get to run and I get the following memory allocation error:Code:
MemoryError: memory allocation failed, allocating 342 byte
I am not convinced it does, as on my RP235X ...Doesn't "max free sz: 2306" mean the largest free memory chunk is 2306 bytes?
Code:
>>> micropython.mem_info(1)stack: 564 out of 7936GC: total: 205568, used: 7456, free: 198112 No. of 1-blocks: 67, 2-blocks: 16, max blk sz: 72, max free sz: 12370...>>> ba = bytearray(65536)>>> micropython.mem_info(1)stack: 564 out of 7936GC: total: 205568, used: 73360, free: 132208 No. of 1-blocks: 79, 2-blocks: 20, max blk sz: 4096, max free sz: 8251
I would guess it couldn't allocate 342 at the time, that failure caused scope to be exited all the way back to the REPL which probably freed stuff on the heap on the way down.How does it fail to allocate 342? Furthermore there are 121kb of free memory, surely there must be a 342b free chunk..?
Possibly. Did you try creating a 32KB byte array at that point ? My guess is it will work.Even more, the memory map (or whatever it is) ends with the following:which means that addresses from 0x1f800 to 0x28800 are free, which is like 36kb?Code:
1f800: ======.......................................................... (35 lines all free)28800: ........
But, given that it won't compile with 32KB allocated in 'boot.py', I suspect you may have hit the limit of what can be supported by what you have. You may need a redesign which involves doing things other than using a monolithic 'main.py'.
But I also agree having 100KB+ free but not being able to allocate 32KB seems odd. You may have to talk to MicroPython about that or figure out what the 'mem_info(1)' report means and shows.
Statistics: Posted by hippy — Wed Jan 15, 2025 11:56 pm