mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
sched: catch task memory leak
Print all unreleased memory blocks when the task exits Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
65dc1fe0fc
commit
2c95c04f4e
2 changed files with 20 additions and 0 deletions
|
|
@ -595,6 +595,14 @@ config SCHED_WAITPID
|
|||
compliant) and will enable the waitid() and wait() interfaces as
|
||||
well.
|
||||
|
||||
config SCHED_DUMP_LEAK
|
||||
bool "Enable catch task memory leak"
|
||||
default n
|
||||
---help---
|
||||
When this option is enabled, the task's outstanding memory allocations
|
||||
are printed using syslog. This helps catch any memory allocated by the
|
||||
task that remains unreleased when the task exits.
|
||||
|
||||
config SCHED_USER_IDENTITY
|
||||
bool "Support per-task User Identity"
|
||||
default n
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
|
|
@ -505,6 +506,17 @@ void nxtask_exithook(FAR struct tcb_s *tcb, int status, bool nonblocking)
|
|||
|
||||
nxsig_cleanup(tcb); /* Deallocate Signal lists */
|
||||
|
||||
#ifdef CONFIG_SCHED_DUMP_LEAK
|
||||
if ((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
|
||||
{
|
||||
kmm_memdump(tcb->pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
umm_memdump(tcb->pid);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
leave_critical_section(flags);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue