← index #9043Issue #996
Likely Duplicate · medium · value 0.792
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

Requirements for heap monitoring/debugging functions

closedby pfalconopened 2014-12-01updated 2022-06-23
enhancement

https://github.com/micropython/micropython/commit/6e8ff9cd6848492547b9e2da29d29acefe2fde95 marks first (previously discussed) step towards port-independent heap monitoring functions. Next step would be to merge useful things from pyb.info() function, but I'd like to think step ahead and consider how to tweaks function(s) to optimize their usefulness in real-world scenarios.

Few ideas:

  1. Would be nice to have affinity towards printing single line of info - to minimize spam when used in quick loops, etc.
  2. Would be nice to by default print short, the most useful information. For example, free/used heap sizes are the most useful params. Next in my list would be size of the largest allocatable free block - based on existing fragmentation reports (we don't have such param repored now, and it's arguably expensive). Next would be stack usage, etc. Things like "largest allocated blocks" and "number of 1-block allocs" goes to tail of the list - I so far see it as a nice trivia, but not really useful for more or less general purpose. Different levels of output may/should be controlled by optional arg to function(s).
  3. There may be need for some flexibility. For example, I'd like see function to dump heap usage bitmap as a single line - to capture progress over time without gross log spamming, to be used with separate visualizations tools. And yet, there would be nice to have functions which uses ASCII art to dump heap state in human-readable form. Again, this can be controlled by function arguments.

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