This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e8bbf496ee9e30a9683bf9f539600763a102c47d Author: ganjing <[email protected]> AuthorDate: Mon Jan 26 14:20:35 2026 +0800 mm: Call mm_free_delaylist in mm_mallinfo and remove it from meminfo_read to enuse caller always get get accuracy memory information. Signed-off-by: ganjing <[email protected]> --- fs/procfs/fs_procfsmeminfo.c | 7 ------- include/nuttx/mm/mm.h | 2 -- mm/mm_heap/mm.h | 4 ++++ mm/mm_heap/mm_foreach.c | 1 + mm/mm_heap/mm_initialize.c | 2 ++ mm/mm_heap/mm_mallinfo.c | 4 ++++ mm/tlsf/mm_tlsf.c | 27 +++++++++++---------------- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index e8b5959b108..7e5b4a80047 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -318,13 +318,6 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, buffer += copysize; buflen -= copysize; - /* Trigger reclamation of delay list otherwise they will be - * counted as used, which often confuses people like memory - * leakages. see pull/12817 for more information. - */ - - mm_free_delaylist(entry->heap); - /* Show heap information */ info = mm_mallinfo(entry->heap); diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index 1daf86c892c..cb21a209d12 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -319,8 +319,6 @@ void kmm_addregion(FAR void *heapstart, size_t heapsize); FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) malloc_like1(2); -void mm_free_delaylist(FAR struct mm_heap_s *heap); - /* Functions contained in kmm_malloc.c **************************************/ #ifdef CONFIG_MM_KERNEL_HEAP diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index e56e334a3fa..2926c6e054b 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -306,6 +306,10 @@ void mm_foreach(FAR struct mm_heap_s *heap, mm_node_handler_t handler, void mm_delayfree(FAR struct mm_heap_s *heap, FAR void *mem, bool delay); +/* Functions contained in mm_malloc.c ***************************************/ + +void mm_free_delaylist(FAR struct mm_heap_s *heap); + /**************************************************************************** * Inline Functions ****************************************************************************/ diff --git a/mm/mm_heap/mm_foreach.c b/mm/mm_heap/mm_foreach.c index a0d4dc9e578..39de77ab661 100644 --- a/mm/mm_heap/mm_foreach.c +++ b/mm/mm_heap/mm_foreach.c @@ -58,6 +58,7 @@ void mm_foreach(FAR struct mm_heap_s *heap, mm_node_handler_t handler, #endif DEBUGASSERT(handler); + mm_free_delaylist(heap); /* Visit each region */ diff --git a/mm/mm_heap/mm_initialize.c b/mm/mm_heap/mm_initialize.c index 2df6570df0e..cf111e8d3cf 100644 --- a/mm/mm_heap/mm_initialize.c +++ b/mm/mm_heap/mm_initialize.c @@ -387,6 +387,8 @@ void mm_uninitialize(FAR struct mm_heap_s *heap) mempool_multiple_deinit(heap->mm_mpool); #endif + mm_free_delaylist(heap); + for (i = 0; i < CONFIG_MM_REGIONS; i++) { if (!heap->mm_nokasan) diff --git a/mm/mm_heap/mm_mallinfo.c b/mm/mm_heap/mm_mallinfo.c index 8a06cd6843e..66f26275269 100644 --- a/mm/mm_heap/mm_mallinfo.c +++ b/mm/mm_heap/mm_mallinfo.c @@ -190,6 +190,7 @@ struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap, size_t mm_heapfree(FAR struct mm_heap_s *heap) { + mm_free_delaylist(heap); return heap->mm_heapsize - heap->mm_curused; } @@ -204,6 +205,9 @@ size_t mm_heapfree(FAR struct mm_heap_s *heap) size_t mm_heapfree_largest(FAR struct mm_heap_s *heap) { FAR struct mm_freenode_s *node; + + mm_free_delaylist(heap); + for (node = heap->mm_nodelist[MM_NNODES - 1].blink; node; node = node->blink) { diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 784ffb5a3e1..9337d20afa6 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -833,6 +833,8 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap) # define region 0 #endif + free_delaylist(heap, true); + /* Visit each region */ #if CONFIG_MM_REGIONS > 1 @@ -1153,6 +1155,8 @@ struct mallinfo mm_mallinfo(FAR struct mm_heap_s *heap) memset(&info, 0, sizeof(struct mallinfo)); + free_delaylist(heap, true); + /* Visit each region */ #if CONFIG_MM_REGIONS > 1 @@ -1197,6 +1201,8 @@ struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap, #define region 0 #endif + free_delaylist(heap, true); + #ifdef CONFIG_MM_HEAP_MEMPOOL info = mempool_multiple_info_task(heap->mm_mpool, task); #endif @@ -1244,6 +1250,8 @@ void mm_memdump(FAR struct mm_heap_s *heap, memset(&priv, 0, sizeof(struct mm_memdump_priv_s)); priv.dump = dump; + free_delaylist(heap, true); + if (pid == PID_MM_MEMPOOL) { syslog(LOG_INFO, "Memdump mempool\n"); @@ -1680,6 +1688,8 @@ void mm_uninitialize(FAR struct mm_heap_s *heap) mempool_multiple_deinit(heap->mm_mpool); #endif + free_delaylist(heap, true); + for (i = 0; i < CONFIG_MM_REGIONS; i++) { if (!heap->mm_nokasan) @@ -1721,22 +1731,6 @@ FAR void *mm_zalloc(FAR struct mm_heap_s *heap, size_t size) return alloc; } -/**************************************************************************** - * Name: mm_free_delaylist - * - * Description: - * force freeing the delaylist of this heap. - * - ****************************************************************************/ - -void mm_free_delaylist(FAR struct mm_heap_s *heap) -{ - if (heap) - { - free_delaylist(heap, true); - } -} - /**************************************************************************** * Name: mm_heapfree * @@ -1747,6 +1741,7 @@ void mm_free_delaylist(FAR struct mm_heap_s *heap) size_t mm_heapfree(FAR struct mm_heap_s *heap) { + free_delaylist(heap, true); return heap->mm_heapsize - heap->mm_curused; }
