Skip to content

Commit 54d5f7c

Browse files
committed
utop: Print IDF heap details.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
1 parent 08e09af commit 54d5f7c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

micropython/utop/utop.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,23 @@ def top(update_interval_ms=1000, timeout_ms=None, thread_names={}):
7979
micropython.mem_info()
8080
line_count += 3
8181

82+
if esp32 is not None:
83+
print("\x1b[K")
84+
line_count += 1
85+
for name, cap in (("data", esp32.HEAP_DATA), ("exec", esp32.HEAP_EXEC)):
86+
heaps = esp32.idf_heap_info(cap)
87+
print(
88+
"IDF heap ({}): {} regions, {} total, {} free, {} largest contiguous, {} min free watermark\x1b[K".format(
89+
name,
90+
len(heaps),
91+
sum((h[0] for h in heaps)),
92+
sum((h[1] for h in heaps)),
93+
max((h[2] for h in heaps)),
94+
sum((h[3] for h in heaps)),
95+
)
96+
)
97+
line_count += 1
98+
8299
if previous_line_count > line_count:
83100
for _ in range(previous_line_count - line_count):
84101
print("\x1b[K")

0 commit comments

Comments
 (0)