In my app I register BroadcastReceiver
programmatically like that and unregister it in appropriate time with respect to my app's business logic.
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {...}
I want to make sure that when my app's process unexpectedly die (get killed) no memory leak is caused by the receiver and if it does what are my options?
(Already check the official doc, this great article and this SO thread )
I want to make sure that when my app's process unexpectedly die (get killed) no memory leak is caused by the receiver and if it does what are my options?
When an app process gets killed by the system (quite) everything associated with the process is "gone". No memory leaks from the app component's (Activity
, Service
, BroadcastReceiver
) side can be expected.
Edit
When process get killed ActivityManagerService
clean all app resources using cleanUpApplicationRecordLocked
method here.
You can clearly see that all resources including all registered broadcast receivers being cleaned.(Ln. 15598)