Suppose I am running my application.During this in my code memory allocation has taken place for various objects . Now i execute a kill command on my unix terminal for the process. In that case how does all the memory deallocation process takes place ? Is this handled entirely by the operating system by deallocating the entire memory for the process ?
Asked
Active
Viewed 228 times
0
-
3A [process](http://en.wikipedia.org/wiki/Process_%28computing%29) has its own [address space](http://en.wikipedia.org/wiki/Address_space) in [virtual memory](http://en.wikipedia.org/wiki/Virtual_memory). When the process is terminated, that address space (and the physical memory it is consuming, and some other resources) is destroyed (to be reusable) by the kernel. – Basile Starynkevitch Sep 21 '14 at 17:12
-
1Memory isn't necessarily the only resource you should be concerned with. – JBentley Sep 21 '14 at 17:15
-
1Possible duplicate of http://stackoverflow.com/questions/16418338/heap-memory-clearance-when-application-closes-abruptly – Christophe Sep 21 '14 at 17:20
1 Answers
3
In general, at process termination, all resources allocated by this process are freed by operating system. (see 3.3.2 Operating System Concepts by Abraham Silberschatz , Peter B. Galvin, Greg Gagne http://www.amazon.com/Operating-System-Concepts-Abraham-Silberschatz/dp/0470128720)
The kill command does not "kill" process, but sends signal to it. If the signal is SIGKILL (kill -9 PID) you can do nothing. Process is killed unconditionally. If signal is SIGTERM (default), you can serve it or ignore it. See: http://en.wikipedia.org/wiki/Unix_signal

Piotr
- 833
- 5
- 12