Coder Social home page Coder Social logo

Comments (2)

vvLavida avatar vvLavida commented on September 27, 2024

关于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.

vvLavida avatar vvLavida commented on September 27, 2024

android应用有内存大小限制是针对进程的。每个进程其实都有一个虚拟机,这个虚拟机最大堆就是它的最大可用内存。

from technotes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.