Print memory usage (p/P) only on change (#56)
* print memory usage (p/P): Only print when changed, max-memory No longer spam the memory usage constantly. This makes the output much more useful by allowing to observe each change in memory usage, since the values now no longer get pushed up and scroll out of view rapidly. Changes: - Add `max_used` peak memory usage - Add labels in the output (slightly more verbose, but much clearer) - Remove unnecessary `int64_t` cast - Change "free" to "budget left" to clarify it shows mem that would be free on the real hardware, making situations where it goes negative less confusing - Change field widths so 5 digit values no longer jump out of alignment Example output: ``` Mem: 6720 used (change: -248, peak: 7928) 7616 budget left Mem: 6832 used (change: +112, peak: 7928) 7504 budget left Mem: 6584 used (change: -248, peak: 7928) 7752 budget left Mem: 10856 used (change: +4272, peak: 10848) 3480 budget left Mem: 10888 used (change: +32, peak: 10880) 3448 budget left Mem: 10616 used (change: -272, peak: 10880) 3720 budget left Mem: 6704 used (change: -3912, peak: 10880) 7632 budget left Mem: 6808 used (change: +104, peak: 10880) 7528 budget left ```
This commit is contained in:
parent
23bf37995c
commit
7ca0e50f1b
17
main.cpp
17
main.cpp
|
@ -832,11 +832,22 @@ public:
|
||||||
lv_obj_del(screen_off_label);
|
lv_obj_del(screen_off_label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_memory_usage) {
|
if (print_memory_usage) {
|
||||||
// print free memory with the knowledge that 14KiB RAM is the actual PineTime-Memory
|
|
||||||
lv_mem_monitor(&mem_mon);
|
lv_mem_monitor(&mem_mon);
|
||||||
printf("actual free_size = %d\n", int64_t(mem_mon.free_size) - (LV_MEM_SIZE - 14U*1024U));
|
if (mem_mon.free_size != mem_mon_last_free_size) {
|
||||||
|
// 14KiB is the LVGL memory size used in InfiniTime
|
||||||
|
constexpr uint32_t pinetime_lvgl_memory = 14U*1024U;
|
||||||
|
uint32_t mem_used = LV_MEM_SIZE - mem_mon.free_size;
|
||||||
|
// The "budget" value shows how much free lvgl memory the PineTime
|
||||||
|
// would have free and will go negative when more memory is used
|
||||||
|
// in the simulator than is available on the real hardware.
|
||||||
|
int32_t budget = pinetime_lvgl_memory - mem_used;
|
||||||
|
printf("Mem: %5u used (change: %+5d, peak: %5u) %d budget left\n", mem_used, mem_mon_last_free_size - mem_mon.free_size, mem_mon.max_used, budget);
|
||||||
|
mem_mon_last_free_size = mem_mon.free_size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gif_manager.is_in_progress())
|
if (gif_manager.is_in_progress())
|
||||||
{
|
{
|
||||||
gif_manager.write_frame();
|
gif_manager.write_frame();
|
||||||
|
@ -883,6 +894,8 @@ private:
|
||||||
bool left_release_sent = true; // make sure to send one mouse button release event
|
bool left_release_sent = true; // make sure to send one mouse button release event
|
||||||
bool right_last_state = false; // varable used to send message only on changing state
|
bool right_last_state = false; // varable used to send message only on changing state
|
||||||
|
|
||||||
|
uint32_t mem_mon_last_free_size = LV_MEM_SIZE;
|
||||||
|
|
||||||
GifManager gif_manager;
|
GifManager gif_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user