Furi: show thread allocation balance for child threads (#1992)

This commit is contained in:
あく
2022-11-10 02:33:09 +09:00
committed by GitHub
parent 9f0aef330e
commit c89e5e11a4
2 changed files with 11 additions and 7 deletions

View File

@@ -12,6 +12,8 @@
#include <furi_hal_rtc.h>
#include <furi_hal_console.h>
#define TAG "FuriThread"
#define THREAD_NOTIFY_INDEX 1 // Index 0 is used for stream buffers
typedef struct FuriThreadStdout FuriThreadStdout;
@@ -82,6 +84,12 @@ static void furi_thread_body(void* context) {
if(thread->heap_trace_enabled == true) {
furi_delay_ms(33);
thread->heap_size = memmgr_heap_get_thread_memory((FuriThreadId)task_handle);
furi_log_print_format(
thread->heap_size ? FuriLogLevelError : FuriLogLevelInfo,
TAG,
"%s allocation balance: %d",
thread->name ? thread->name : "Thread",
thread->heap_size);
memmgr_heap_disable_thread_trace((FuriThreadId)task_handle);
}
@@ -89,8 +97,8 @@ static void furi_thread_body(void* context) {
if(thread->is_service) {
FURI_LOG_E(
"Service",
"%s thread exited. Thread memory cannot be reclaimed.",
TAG,
"%s service thread exited. Thread memory cannot be reclaimed.",
thread->name ? thread->name : "<unknown service>");
}