Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the force kill command (kill -9) in linux cleanup the dynamically allocated memory with new operator in C++ application?

I have a C++ application to be run on Oracle Linux OS.

Consider, I have created few objects with new operator. Though I have used delete operator to deallocate it, but the force kill command would not reach this implementation.

But, if I force kill (kill -9) the process, will the dynamically allocated memory (using new operator) be de-allocated by the operating system? As I am not able to find the straightforward answer to this, I would like to have some information.

Thanks in advance.

like image 874
Vijaykumar Ainapur Avatar asked Aug 31 '20 09:08

Vijaykumar Ainapur


People also ask

What is task_struct in Linux kernel?

From what I think I've understood, task_struct is the C structure that acts as the process descriptor, holding everything the kernel might need to know about a processes. At the end of the process kernel stack lives another struct, thread_info , which has a pointer to the processes task_struct .

How does Debugfs work?

Debugfs exists as a simple way for kernel developers to make information available to user space. Unlike /proc, which is only meant for information about a process, or sysfs, which has strict one-value-per-file rules, debugfs has no rules at all. Developers can put any information they want there.

What is Module_init?

module_init is used to mark a function to be used as the entry-point of a Linux device-driver. It is called. during do_initcalls() (for a builtin driver) at module insertion time (for a *.ko module)

How do I enable KGDB?

In order to use kgdb you must activate it by passing configuration information to one of the kgdb I/O drivers. If you do not pass any configuration information kgdb will not do anything at all. Kgdb will only actively hook up to the kernel trap hooks if a kgdb I/O driver is loaded and configured.


1 Answers

But, if I force kill (kill -9) the process, will the dynamically allocated memory (using new operator) be de-allocated by the operating system?

Memory is tied to a process through the virtual memory system and the memory management unit (MMU). Thus yes, all memory (not just the one allocated through new) will be freed.

Exceptions to this are global inter-process communication (IPC) resources like shared memory, cached files, etc.

like image 172
Acorn Avatar answered Sep 28 '22 03:09

Acorn