Freeing Application resources
<p>Usually resources such as threads, services, memory allocation... are allocated and defined per Activity.
Hence, resources will be allocated on Activity.onCreate() and freed on Activity.pause().
This is very well defined.</p>

<p>But, suppose my resources are allocated per Application (i.e I define a service which is used by several activities, OR, I instantiate a thread in the Native layer using NDK). Allocating these resources is not a problem. It can simply be done when the first Activity starts. The problem is - when should these resources by freed? How do I know when my application ends? 
According to the documentation: <a href="http://developer.android.com/reference/android/app/Application.html#onTerminate" rel="nofollow">http://developer.android.com/reference/android/app/Application.html#onTerminate</a>() - " <strong>Note: never depend on this method being called; in many cases an unneeded application process will simply be killed by the kernel without executing any application code."</strong></p>

<p>Any ideas anyone?</p>

<p>Thanks,
Eyal </p>
