Android has a certain limit on memory, and the memory limit on many phones is completely different. Our application is actually a process, the process is completely independent, this process allocates memory is certain, so we often encounter oom problem. However, what you may not know is that you can specify that some components of the application run in different processes, rather than the one that is used to start the application.
The only thing we need is a property:
Android:process
This process property can be used for activities, services, content providers, and broadcast receivers and specific components that should be executed in the specified process.
In this example, I specify that Musicservice must perform the process in a separate "music":
<Manifest...> <ApplicationAndroid:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/theme.main" > <ActivityAndroid:name=". Musicactivity " /> <ServiceAndroid:name=". Musicservice "android:process= ": Music" /> </Application></Manifest>
So that we can put different components into different processes, and their own memory will become larger. However, there is the problem of how to communicate between multiple processes. Fortunately intent can "travel" across processes, handlers and messengers can also. You can also rely on aidl (Android Interface Definition language) and binder.
In short, everything is not absolute, this method is suitable for some of the layers are relatively clear and functionally independent modules, if you want to know more about this problem can refer to this article.
Reference from:
https://github.com/bboyfeiyu/android-tech-frontier/tree/master/androidweekly/%E6%AC%A2%E8%BF%8E%E6%9D%A5%E5%88 %b0android%e5%a4%9a%e8%bf%9b%e7%a8%8b%e6%97%b6%e4%bb%a3
Using the Android multi-process mechanism to split components