I have a startable service which is bound to separate process.
When service has been started a process is born.
But when service was stopped the process still alive and consuming RAM.
How to kill this process correctly?
Is it correct to call exitProcess(0) from a onDestoy method of the service?
3
When your service is stopped, the process is moved to the “cached” list and the OS will reclaim that memory when needed. You do not need to (and should not try to) manage that lifecycle yourself. If your service is re-started later and the process is still in the cached list, the OS is able to efficiently re-use the existing process.
1