diff options
author | Marvin Borner | 2021-04-02 13:05:50 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-02 13:05:50 +0200 |
commit | 3e81b8a254485de532d46c9a0710be97879d0605 (patch) | |
tree | b51e1dda3e3b6302c6bc8fa7586b8069ee602123 /kernel/features | |
parent | 192b756a6999a0637fcc72f3fd2f9f7099e32543 (diff) |
Added memory leak detector
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/mm.c | 10 | ||||
-rw-r--r-- | kernel/features/proc.c | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 5356ab4..afee468 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -404,16 +404,6 @@ void memory_map_identity(struct page_dir *dir, struct memory_range prange, u32 f memset((void *)prange.base, 0, prange.size); } -struct memory_object { - u32 id; - u32 refs; - u8 shared; - struct memory_range prange; -}; -struct memory_proc_link { - struct memory_object *obj; - struct memory_range vrange; -}; static struct list *memory_objects = NULL; res memory_sys_alloc(struct page_dir *dir, u32 size, u32 *addr, u32 *id, u8 shared) { diff --git a/kernel/features/proc.c b/kernel/features/proc.c index a17a655..52627ed 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -148,6 +148,16 @@ void proc_exit(struct proc *proc, struct regs *r, s32 status) proc->name[0] ? proc->name : "UNKNOWN", proc->pid, status, status == 0 ? "success" : "error"); + if (proc->memory->head) { + printf("Process leaked memory:\n"); + struct node *iterator = proc->memory->head; + while (iterator) { + struct memory_proc_link *link = iterator->data; + printf("\t-> 0x%x: %dB\n", link->vrange.base, link->vrange.size); + iterator = iterator->next; + } + } + stack_destroy(proc->messages); list_destroy(proc->memory); // TODO: Decrement memory ref links virtual_destroy_dir(proc->page_dir); |