Comments (2)
关于Process的使用最常见的例子是Service。针对Service进行使用需要考虑两种情况:
情况1.应用中有Activity部分有会使用较多的UI,占用较多的内存资源,并且要求Activity退到后台情况下要求Service在后台运行。因为Android本身有Low Memory Killer这套机制,在系统内存吃紧的情况下会去会砍掉内存占用较多(一般是OOM_ADJ值较大的Process),此时因为有Service在后台运行,所以会降低OOM_ADJ,Low Memory Killer在砍Process的时候就不容易将此部分内存回收。此时可以考虑将Service从应用进程中分离出来,这样Low Memory Killer在回收内存时会将因为Activity部分占用的内存较大,OOM_ADJ较大,优先将其砍掉释放内存。同时保证Service正常运行。
情况2.在系统中有很多有共性的Service,同时应用中Activity显示部分的UI不多或者没有Activity.可以将这些Service合并成同一个进程。因为android没启动一个进行,在zygote fork阶段会预载于一部分资源占用内存(具体几M记不清楚了),通过将Service合并,可以节省这部分开销。
from technotes.
android应用有内存大小限制是针对进程的。每个进程其实都有一个虚拟机,这个虚拟机最大堆就是它的最大可用内存。
from technotes.
Related Issues (20)
- Groovy in Gradle
- HTTP API自动化测试
- HTTPS安全在哪里? HOT 1
- FlatBuffers
- Android里面的Deep linking HOT 1
- Android原理篇
- 跨平台方案
- 如何提高Android代码的可测试性?
- 如何提高Android代码的可测试性?
- Android应用架构选型(MVC MVVM MVP Flux Clean) HOT 6
- Android任务列表中滑动删除应用后都发生了什么?
- Android Patch方案比较
- 基于AOP的方法级自动埋点
- Android tricks
- Android Router HOT 1
- 爬虫环境搭建
- React & Redux
- JavaScript引擎 HOT 3
- 浏览器内核 HOT 7
- 移动web tips
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from technotes.