From 2ffca6d16dec2c976fdaa406a7c46ab816425620 Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Sat, 26 Mar 2022 23:27:21 +0800 Subject: [PATCH] mm/mm_heap: output mallinfo when malloc failed Signed-off-by: Jiuzhu Dong --- mm/mm_heap/mm_malloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index 51c789d634..135e1f3f1c 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -243,7 +244,13 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) #ifdef CONFIG_DEBUG_MM else { + struct mallinfo minfo; + mwarn("WARNING: Allocation failed, size %zu\n", alignsize); + mm_mallinfo(heap, &minfo); + mwarn("Total:%d, used:%d, free:%d, largest:%d, nused:%d, nfree:%d\n", + minfo.arena, minfo.uordblks, minfo.fordblks, + minfo.mxordblk, minfo.aordblks, minfo.ordblks); mm_memdump(heap, -1); DEBUGASSERT(false); }