← index #9043Issue #5650
Related · high · value 0.952
QUERY · ISSUE

More flexible memory analysis with `micropython.mem_info()`

openby AmirHmZzopened 2022-08-12updated 2022-08-12
enhancement

I think it would be a good idea to make micropython.mem_info(1) yields table of heap utilisation in a specific format in a streaming manner. It could be used to analyise and profile memory on another device easily. This idea also applies to micropython.mem_info() as it just prints some stuff and not returning anything.

CANDIDATE · ISSUE

mem_info reports impossible values

openby osresearchopened 2020-02-15updated 2020-02-16

Tracing m_malloc() and m_free() calls, it looks like the free rarely gets called, so the reported memory usage keeps climbing and current_bytes_allocated is significantly larger (34KB) than the heap + stack (29KB) after a while:

>>> micropython.mem_info()
mem: total=43806, current=33642, peak=34475
stack: 428 out of 5512
GC: total: 24000, used: 7888, free: 16112
 No. of 1-blocks: 184, 2-blocks: 26, max blk sz: 18, max free sz: 373

This might be a bug in my port; I'm using the minimal gc_collect() that has a comment about it "may function incorrectly".

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