English 中文(简体)
如何强制暂停的进程内存进行交换?
原标题:How to force a paused process memory into swap?

我正在寻找方法来改善内存为256MB的Android设备的用户界面,以防止滞后。内存是如此有限,以至于大型前端应用程序会触发许多其他应用程序的交换。

The idea is: If an background app (a Facebook app for example) is not necessary to run continuously, unlike, say telephony, which must stay uninterrupted, just pause that app s process, and continue to run it every a few minutes to retrieve updates, only when the cellphone is idle in the pocket, and then pause the process again.

For reducing lag swapping out other apps memory, I want the paused apps memory can be proactively swapped to disk/flash, so the RAM can be instantly released in order the frondend app needs. (reference speed: class 10 SDHC: 10MB/s write, so the browser lags for 2 seconds if a webpage need to claim 20MB RAM)

So my question is: How to force the system to swap a paused process private memory into disk/flash?

问题回答

如果需要ram,则非活动进程会自动进入交换状态,因为ram的优先级较低(请参阅android上的优先级)。

Theorically, a class 10 card is good and could only make swap in 2 seconds, but the card s memory controller is so long that you will have 5 or 6 seconds. Having more that a class 6 is not usefull.

Android已经处理了暂停应用程序的内存,但与其将进程交换到一些虚拟内存(这可能很昂贵),不如在需要时转储它们以释放内存。

发件人:Android开发人员文档-管理活动生命周期

如果一个活动被暂停或停止,系统可以通过要求它完成(调用其finish()方法)或简单地终止其进程来将其从内存中删除。当活动再次打开时(在完成或终止后),必须重新创建。

activity sonPause()是保证运行的生命周期回调中的最后一个,允许它保存状态,之后Android可以根据需要愉快地转储它。

发件人:在同一文档中进一步

…如果系统必须在紧急情况下恢复内存,那么onStop()和onDestroy()可能不会被调用。因此,您应该使用onPause()将关键的持久数据(如用户编辑)写入存储。但是,您应该选择在onPause()期间必须保留哪些信息,因为此方法中的任何阻塞过程都会阻止向下一个活动的转换,并减缓用户体验。

(添加了强调

因此,你可能会遇到的瓶颈可能是应用程序本身,而不是操作系统,保存活动状态仍然可能比尝试存储整个应用程序的内存内容快得多。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签