mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
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 <ganjing@xiaomi.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
****************************************************************************/
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
+11
-16
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user