Reputation: 820
Anytime I try to close my foreground service, my app continues running even when none of my activities are opened. I've made a few allocation and function tracing tests and noticed that, however, my app is still open and uses a few MB of memory none of my methods are being called after closing the service. Only Java and Android stuff. Oh, and it looks like that my app also leaks memory during this. According to my app's Java heap, there are thousands of FinalizerReferences instantiated. Can this cause such a big problem or why can this occur?
This is how it looks like:
Upvotes: 1
Views: 353
Reputation: 68
Calling finish() when you want to shut down the app completely should kill the app and free it's resources.
Upvotes: 0
Reputation: 722
Its Default android property, the app continiues to run in background even after you have closed ur app, few features like services etc run in background. Either you forcefully exis the app which i wouldnt suggest, or let android automatically close it when it requires
Upvotes: 1
Reputation: 22347
This is how android works, every activity and service you have, executes inside only one thread called UI thread which itself and other threads you create run in a single process.
Android doesn't close this process till systme has enough memory for new stuff so if you user wants to run your program again it launch's as fast as possible. But you can terminate the whole process using exit() function.
Actually the activity or service is not the program but piece of code which runs inside the UI thread inside program process, now the process is your program which can be started even with a broadcast receiver call!
Upvotes: 0
Reputation: 15775
Android apps and their components have unique life cycles. See here: http://developer.android.com/guide/components/processes-and-threads.html
Upvotes: 0