android:process
定义activity运行所在的进程名称。一般情况下,应用的所有组件都运行在为应用创建的默认的进程中,该默认进程的名称应用包名称一致。通过定义<application>元素的“process”属性可以为所有组件指定一个不同的默认进程。但是任意组件都可以重写默认进程,以便实现多进程操作。
如果该属性指定名称以“:”开头,则一个新的专属于该应用的进程将会被创建。如果该进程名以小写字母开头,则为该activity提供权限以让其在一个全局的进程中运行。这样会允许多个应用的不同组件共用一个进程,以便节省资源。
Android是支持多进程的,每个进程的内存使用限制一般为24MB的内存,所以当完成一些很耗费内存的操作如处理高分辨率图片时,需要单独开一个进程来执行该操作(上面的配置可以用来实现该操作)。即便如此,开发者还是不要随意多开进程来耗费用户的资源。(内存限制,有16MB,24MB,
32MB,很老的机型的内存限制会是16MB,这个具体还要再搜索下资料。。)
另外一些还有一些其他的方式来绕过内存限制,使用更多的资源来完成自己的任务,如下文(有待实践):
How to work around Android’s 24 MB memory limit
The Android framework enforces a per-process 24 MB memory limit. On some older devices, such as the G1, the limit is even lower at 16 MB.
What’s more, the memory used by Bitmaps is included in the limit. For an application manipulating images it is pretty easy to reach this limit and get the process killed with
an OOM exception:
E/dalvikvm-heap(12517): 1048576-byte external allocation too large for this process.
E/GraphicsJNI(12517): VM won't let us allocate 1048576 bytes
D/AndroidRuntime(12517): Shutting down VM
W/dalvikvm(12517): threadid=1: thread exiting with uncaught exception (group=0x4001d7f0)
E/AndroidRuntime(12517): FATAL EXCEPTION: main
E/AndroidRuntime(12517): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
This limit is ridiculously low. For a device, like the Nexus One, with 512MB of physical RAM, setting the per-process memory limit for the foreground activity to only 5% of the RAM is a silly mistake.
But anyway, that’s how things are and we have to live with it
— i.e. find how to work around it.
There are two ways to allocatemuchmore memory than the limit:
One way is to allocate memory from native code. Using the NDK (native development kit) and JNI, it’s possible to allocate memory from the C level (e.g. malloc/free or new/delete),
and such allocations are not counted towards the 24 MB limit. It’s true, allocating memory from native code is not as convenient as from Java, but it can be used to store some large amounts of data in RAM (even image data).
Another way, which works well for images, is to use OpenGL textures
— the texture memory is not counted towards the limit.
To see how much memory your app has really allocated you can use android.os.Debug.getNativeHeapAllocatedSize().
Using either of the two techniques presented above, on a Nexus One, I could easily allocate 300MB for a single foreground process
— more than 10 times the default 24 MB limit.
相关推荐
android检查内存泄露和用法 <!--==============================================================================--> android:name="com.squareup.leakcanary.internal.HeapAnalyzerService" android:enabled...
这本书是一本不可多得的好书。强烈推荐相关测试及开发、管理人员阅读。同时软件分析与测试方面的研究人员也可以将这本书作为入门参考。 这本书的两位作者分别是Mauro Pezzè和Michal Young,两位作者的主页分别是:...
android的启动速度、虚拟机heapsize的大小调整、watchdog工作原理等问题;第5章讲解了android系统中常用的类,包括sp、wp、refbase、thread等类,同步类,以及java中的handler类和 looper类,掌握这些类的知识后方...
《深入理解Android:卷2》共8章:第1章介绍了阅读本书所需要做的准备工作,包括Android 4.0源码的下载和编译、Eclipse环境的搭建,以及Android系统进程(system_process)的调试等;第2章对Java Binder和MessageQueue...
使用android:process和Process.killProcess和UncaughtExceptionHandler完成Android应用程序不异常退出
配置AndroidManifest.xml 使用百度SDK时,应用的AndroidManifest.xml主要需要注意以下三项: 4.1、权限 不同的功能需要申请不同的权限,因此在实际使用时,最好参考... android:process=":remote"> ............
最快最简单解决手机中进程“android.process.acore”已停止运行问题.docx
android:process=":x" android:authorities="virtual.service.BinderProvider" android:name="com.lody.virtual.service.BinderProvider" android:exported="false" /> android:theme="@android:style...
一个基于Boost::Process & ZeroMQ方案的C++多进程并发muiltprocessing-master.zip
JakeWharton最新力作——Process Phoenix,重启application process.zip,凤凰进程有助于重新启动您的应用程序进程。
Platform Developer I Certification Prep: Process Automation and Logic
1:Android一个app可以启动2个进程 2:进程A与进程B互相守护 3:进程A时刻盯着进程B,通用进程B也时刻盯着进程B 4:进程之间互相盯着,需要用到IPC进程间通信技术(也就是Binder机制AIDL 5:注意配置远程服务启动为...
但是如果程序在一次操作中打开几个M的文件,那么通常会出现下面的错误信息。 02-04 21:46:08.703: ERROR/dalvikvm-heap(2429): 1920000-byte external allocation too large for this process
"Mobile Applications Development with Android: Technologies and Algorithms" English | ISBN: 1498761860 | 2017 | 320 pages | PDF | 7 MB Mobile Applications Development with Android: Technologies and ...
android 混淆出错 Can't process class 解决办法
美化图标.优化类.点心通讯录.别代码:<uses-sdk android:minSdkVersion="7" /> <uses-permission android:name="android.permission... <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /
在Android中,如果想退出Android程序,一般都是调用finish()、System.exit(0)android.os.Process.killProcess(android.os.Process.myPid())等方法来实现退出程序功能,可是在实际开发中,并不能达到完全退出应用程序...
NSIS Processwork.dll 插件 下载以后就可以用Processwork::KillProcess 杀进程了 用法: Processes::KillProcess "NSIS.exe" Push "NSIS.exe" Processwork::KillProcess
1、contacts的androidmanifest.xml android:process="android.process.acore"说明此应用程序运行在acore进程中。 DialtactsActivity的intent-filter的action属性设置为main,catelog属性设置为launcher,所以此...
<service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote"> 2.manifest下的application内提供ak: android:name="com.baidu.lbsapi.API_KEY" android:value="输入你注册...