← index #3138PR #12366
Related · medium · value 1.644
QUERY · ISSUE

gc threshold calculation in docs/reference/constrained

openby peterhinchopened 2017-06-11updated 2017-07-02
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 · PULL REQUEST

py/gc & esp32: Include largest free block in gc.mem_free() if MICROPY_GC_SPLIT_HEAP_AUTO is enabled

mergedby projectgusopened 2023-09-05updated 2023-09-19
port-esp32py-core

This is a follow-up to #12141 based on discussions in #12316, and changes the behaviour of the esp32 port only.

  • Add the "max new split" value to the result of gc.mem_free(), to give a more accurate impression of how much RAM is available for Python code to use.
  • Update esp32 docs to match, and clarify that gc.mem_alloc() and gc.mem_free() functions are relevant for Python allocations only.

This work was funded through GitHub Sponsors.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied