QUERY · ISSUE
gc threshold calculation in docs/reference/constrained
docs
This has
gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
which sets the threshold to 1/4 of the total RAM regardless of the amount allocated. Shouldn't this read
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
to account for RAM already allocated?
CANDIDATE · ISSUE
esp8266 : available heap: DRAM ?
enhancement
Reading this doc
https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map
there is a region of memory, called DRAM:
User data RAM. Available to applications.
It is 80 KB.
Does the micropython firmware use it?
If not, is it possible to merge this region the the heap?
MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266
At startup I have about 35 KB of free heap, running only this boot.py
from micropython import alloc_emergency_exception_buf
alloc_emergency_exception_buf(100) # give traceback info when RAM allocation would fail
import gc
gc.enable()
#gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
import esp
esp.osdebug(None)
esp.sleep_type(esp.SLEEP_NONE)
from machine import freq
freq(160000000) # CPU at 160 MHz
try :
from sys import tracebacklimit
tracebacklimit(10)
except :
pass
#import uos
# detach REPL UART (GPIO1, 3; disable print, also via USB)
#uos.dupterm(None, 1) # disable REPL on UART(0)
gc.collect()
print("boot.py", gc.mem_free())