开发项目遇到一个问题,打开10个左右的应用后,再打开其他应用就会报错

01-01 12:04:25.937  3958  3958 E ProcessState: Using /dev/binder failed: unable to mmap transaction memory.
01-01 12:04:25.938  3958  3958 F ProcessState: Binder driver could not be opened.  Terminating.
01-01 12:04:25.939  3958  3958 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 3958 (detc.usermanual), pid 3958 (detc.usermanual)
01-01 12:04:25.980   295   386 V APM_AudioPolicyManager: stopOutput() output 29, stream 1, session 25
01-01 12:04:25.980   295   386 V APM_AudioPolicyManager: setBeaconMute(1) mBeaconMuteRefCount=0 mBeaconPlayingRefCount=0
01-01 12:04:25.981   295   386 V APM_AudioPolicyManager: getNewOutputDevice() selected device 0
01-01 12:04:25.981   295   386 V APM_AudioPolicyManager: setOutputDevice() device 0000 delayMs 136
01-01 12:04:25.981   295   386 V APM_AudioPolicyManager: setOutputDevice() prevDevice 0x0001
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 0, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 1, device 0x1
01-01 12:04:25.981   295   386 W APM::AudioPolicyEngine: !!! test route sdpif(524291, 524288)...
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 2, device 0x80000
01-01 12:04:25.981   295   386 W APM::AudioPolicyEngine: !!! test route sdpif(524291, 524288)...
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 2, device 0x80000
01-01 12:04:25.981   295   386 W APM::AudioPolicyEngine: !!!332 device = 80000
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 3, device 0x80000
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 0, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 4, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 5, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 6, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 7, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 8, device 0x2
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 9, device 0x1
01-01 12:04:25.981   295   386 V APM::AudioPolicyEngine: ===>end is getDeviceForStrategyInt() strategy 10, device 0x1
01-01 12:04:25.981   295   386 V APM_AudioPolicyManager: setOutputDevice() setting same device 0x0000 or null device
01-01 12:04:25.982   485   949 D AudioService: onAudioStreamChanged(1, 25, 0, 29)
01-01 12:04:25.982   485   949 D DfAudioManager: remove player session: 25
01-01 12:04:25.982   485   949 D AudioService: requestAmpOnAudioStreamChanged data.streamType = 1  data.status =  0
01-01 12:04:25.985  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255
01-01 12:04:25.985  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:26.036  1202  1374 D ms      : update time: FA 55 E7 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:26.039  1202  1374 D ms      : MCU-onCarBody U_TuenSignal: 255
01-01 12:04:26.046  3972  3972 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
01-01 12:04:26.047   313   313 I /system/bin/tombstoned: received crash request for pid 3958
01-01 12:04:26.048  3972  3972 I crash_dump32: performing dump of process 3958 (target tid = 3958)
01-01 12:04:26.051  3972  3972 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-01 12:04:26.055  3972  3972 F DEBUG   : Build fingerprint: 'Android/sabresd_6dq/sabresd_6dq:8.0.0/1.0.0-rfp-rc4/20180205:eng/dev-keys'
01-01 12:04:26.055  3972  3972 F DEBUG   : Revision: '0'
01-01 12:04:26.055  3972  3972 F DEBUG   : ABI: 'arm'
01-01 12:04:26.055  3972  3972 F DEBUG   : pid: 3958, tid: 3958, name: detc.usermanual  >>> com.detc.usermanual <<<
01-01 12:04:26.055  3972  3972 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-01 12:04:26.080  3972  3972 F DEBUG   : Abort message: 'Binder driver could not be opened.  Terminating.'
01-01 12:04:26.080  3972  3972 F DEBUG   :     r0 00000000  r1 00000f76  r2 00000006  r3 00000008
01-01 12:04:26.080  3972  3972 F DEBUG   :     r4 00000f76  r5 00000f76  r6 bedafdd4  r7 0000010c
01-01 12:04:26.080  3972  3972 F DEBUG   :     r8 00000000  r9 b0d04000  sl 70a6e708  fp 00000000
01-01 12:04:26.080  3972  3972 F DEBUG   :     ip 00000000  sp bedafdc0  lr b0f84d9f  pc b0f7e6bc  cpsr 20070030
01-01 12:04:26.172  1202  1374 D ms      : MCU-onCarBody U_TuenSignal: 255
01-01 12:04:26.222  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 EB 04 35 21 FF A7 
01-01 12:04:26.222  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 EC 04 35 22 FF A6 
01-01 12:04:26.222  1202  1374 D ms      : U_HDVideoPlayReq = 255
01-01 12:04:26.256  1244  1596 D TXZ::CIPManager::getIP: getIP _0[ip_manager.cpp:52]
01-01 12:04:26.256  1244  1596 D TXZ::CIPManager::getIP: getIP _1[ip_manager.cpp:77]
01-01 12:04:26.256  1244  1596 D TXZ::CIPManager::getIP: getIP _2[ip_manager.cpp:89]
01-01 12:04:26.256  1244  1596 D TXZ::CDNSManager::getIPByDomain: domain=conn1.txzing.com[dns_manager.cpp:211]
01-01 12:04:26.256  1244  1596 D TXZ::CDNSManager::getHostByName: [domain=conn1.txzing.com][dns_manager.cpp:101]
01-01 12:04:26.257  1244  1596 D TXZ::CDNSManager::getIPByDomain: domain=conn2.txzing.com[dns_manager.cpp:211]
01-01 12:04:26.257  1244  3973 D TXZ::getIPbyDomainSystem: getIPbyDomainSystem: conn1.txzing.com[get_host_by_name.cpp:25]
01-01 12:04:26.257  1244  1596 D TXZ::CDNSManager::getHostByName: [domain=conn2.txzing.com][dns_manager.cpp:101]
01-01 12:04:26.258  1244  1596 E TXZ::CIPManager::getIP: doman ip list empty[ip_manager.cpp:106]
01-01 12:04:26.258  1244  1596 E TXZ::CConnSvrMgr::_DoConnect: getIP fail: m_u32ConnectInterval=1[connsvr_mgr.cpp:218]
01-01 12:04:26.262  1244  3946 E TXZ::event_dns_timeout_callback: dns[conn1.txzing.com] timeout[get_host_by_name.cpp:107]
01-01 12:04:26.263  1244  3946 E TXZ::CDNSManager::DoDnsInThread: ERROR:getIPbyDomain(conn1.txzing.com) error.[dns_manager.cpp:83]
01-01 12:04:26.263  1244  3946 D TXZ::CDNSManager::DoDnsInThread: [domain=conn1.txzing.com] cost time(3009)[dns_manager.cpp:91]
01-01 12:04:26.264  1244  3975 D TXZ::getIPbyDomainSystem: getIPbyDomainSystem: conn2.txzing.com[get_host_by_name.cpp:25]
01-01 12:04:26.267  1244  3947 E TXZ::event_dns_timeout_callback: dns[conn2.txzing.com] timeout[get_host_by_name.cpp:107]
01-01 12:04:26.267  1244  3947 E TXZ::CDNSManager::DoDnsInThread: ERROR:getIPbyDomain(conn2.txzing.com) error.[dns_manager.cpp:83]
01-01 12:04:26.267  1244  3947 D TXZ::CDNSManager::DoDnsInThread: [domain=conn2.txzing.com] cost time(3013)[dns_manager.cpp:91]
01-01 12:04:26.270  1244  3973 E TXZ::getIPbyDomainSystem: get addr info failed: conn1.txzing.com[get_host_by_name.cpp:35]
01-01 12:04:26.273  1202  1374 D ms      : update time: FA 55 ED 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:26.273  1244  3973 D TXZ::getIPbyDomainLibEvent: getIPbyDomainLibEvent[0][1]: conn1.txzing.com[get_host_by_name.cpp:119]
01-01 12:04:26.276  1244  3975 E TXZ::getIPbyDomainSystem: get addr info failed: conn2.txzing.com[get_host_by_name.cpp:35]
01-01 12:04:26.276  1244  3975 D TXZ::getIPbyDomainLibEvent: getIPbyDomainLibEvent[0][1]: conn2.txzing.com[get_host_by_name.cpp:119]
01-01 12:04:26.283  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:26.334  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255
01-01 12:04:26.335   269   269 E ion     : ioctl c0144900 failed with code -1: Out of memory
01-01 12:04:26.335   269   269 I display : alloc cache buffer err:-12
01-01 12:04:26.392  1225  1345 D AudioManager: getCurrentAudioFocusPackageName  = cn.kuwo.kwmusiccar
01-01 12:04:26.392  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 F0 04 35 21 FF A7 
01-01 12:04:26.443  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 F1 04 35 22 FF A6 
01-01 12:04:26.443  1202  1374 D ms      : U_HDVideoPlayReq = 255
01-01 12:04:26.494  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255
01-01 12:04:26.494  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:26.545  1202  1374 D ms      : update time: FA 55 F4 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:26.551  1202  1374 D ms      : MCU-onCarBody U_TuenSignal: 255
01-01 12:04:26.653  1202  1374 D ms      : MCU-onCarBody U_TuenSignal: 255
01-01 12:04:26.704  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 F8 04 35 21 FF A7 
01-01 12:04:26.704  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 F9 04 35 22 FF A6 
01-01 12:04:26.704  1202  1374 D ms      : U_HDVideoPlayReq = 255
01-01 12:04:26.756  1202  1374 D ms      : update time: FA 55 FB 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:26.763  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:26.814  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255
01-01 12:04:26.814  1202  1374 D ms      : update time: FA 55 FE 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:26.897  1225  1345 D AudioManager: getCurrentAudioFocusPackageName  = cn.kuwo.kwmusiccar
01-01 12:04:26.921  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 00 04 35 21 FF A7 
01-01 12:04:26.971  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 01 04 35 22 FF A6 
01-01 12:04:26.972  1202  1374 D ms      : U_HDVideoPlayReq = 255
01-01 12:04:26.972  1202  1374 D ms      : update time: FA 55 02 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:27.031  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:27.031  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255
01-01 12:04:27.031  1202  1374 D ms      : MCU-onCarBody U_TuenSignal: 255
01-01 12:04:27.047  3972  3972 F DEBUG   : 
01-01 12:04:27.047  3972  3972 F DEBUG   : backtrace:
01-01 12:04:27.047  3972  3972 F DEBUG   :     #00 pc 0001a6bc  /system/lib/libc.so (abort+63)
01-01 12:04:27.047  3972  3972 F DEBUG   :     #01 pc 0000665f  /system/lib/liblog.so (__android_log_assert+154)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #02 pc 00055311  /system/lib/libbinder.so (android::ProcessState::ProcessState(char const*)+280)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #03 pc 000551a7  /system/lib/libbinder.so (android::ProcessState::self()+50)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #04 pc 00001fbd  /system/bin/app_process32 (android::AppRuntime::onZygoteInit()+16)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #05 pc 005cd4cf  /system/framework/arm/boot-framework.oat (offset 0x5cd000) (android.os.Binder.blockUntilThreadAvailable [DEDUPED]+94)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #06 pc 013af035  /system/framework/arm/boot-framework.oat (offset 0x5cd000) (com.android.internal.os.ZygoteConnection.handleChildProc+652)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #07 pc 013b04b3  /system/framework/arm/boot-framework.oat (offset 0x5cd000) (com.android.internal.os.ZygoteConnection.runOnce+1962)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #08 pc 013b0de5  /system/framework/arm/boot-framework.oat (offset 0x5cd000) (com.android.internal.os.ZygoteServer.runSelectLoop+716)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #09 pc 013b4555  /system/framework/arm/boot-framework.oat (offset 0x5cd000) (com.android.internal.os.ZygoteInit.main+2708)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #10 pc 003e1171  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #11 pc 003e5bf1  /system/lib/libart.so (art_quick_invoke_static_stub+228)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #12 pc 000aca91  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+180)
01-01 12:04:27.048  3972  3972 F DEBUG   :     #13 pc 00335cf1  /system/lib/libart.so (art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::ArgArray*, art::JValue*, char const*)+52)
01-01 12:04:27.049  3972  3972 F DEBUG   :     #14 pc 00335b01  /system/lib/libart.so (art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+296)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #15 pc 00286097  /system/lib/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+430)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #16 pc 000d53fd  /system/lib/libart.so (art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+1784)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #17 pc 000c8a43  /system/lib/libart.so (art::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+38)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #18 pc 0006f903  /system/lib/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+38)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #19 pc 00071103  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+446)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #20 pc 00001b19  /system/bin/app_process32 (main+756)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #21 pc 00017db5  /system/lib/libc.so (__libc_init+48)
01-01 12:04:27.050  3972  3972 F DEBUG   :     #22 pc 00001744  /system/bin/app_process32 (_start_main+88)
01-01 12:04:27.082  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255
01-01 12:04:27.082  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:27.132  1202  1374 D ms      : MCU-onCarBody U_TuenSignal: 255
01-01 12:04:27.183  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 0A 04 35 21 FF A7 
01-01 12:04:27.183  1202  1374 D ms      : touch-data start: 0,length 8 offset:2    data : FA 55 0B 04 35 22 FF A6 
01-01 12:04:27.183  1202  1374 D ms      : U_HDVideoPlayReq = 255
01-01 12:04:27.234  1202  1374 D ms      : update time: FA 55 0C 0E 37 22 00 00 00 00 00 00 00 00 00 00 00 99 
01-01 12:04:27.239  1202  1374 D ms      : MCU-onCarBody U_ManuelGearState: 255
01-01 12:04:27.239  1202  1374 D ms      : MCU-onCarBody U_AutoGear_Rev: 255

 

log中有一句ProcessState: Binder driver could not be opened.  Terminating.,看样子是binder通信的问题,追踪代码在

frameworks/native/libs/binder/ProcessState.cpp发现

ProcessState::ProcessState(const char *driver)
    : mDriverName(String8(driver))
    , mDriverFD(open_driver(driver))
    , mVMStart(MAP_FAILED)
    , mThreadCountLock(PTHREAD_MUTEX_INITIALIZER)
    , mThreadCountDecrement(PTHREAD_COND_INITIALIZER)
    , mExecutingThreadsCount(0)
    , mMaxThreads(DEFAULT_MAX_BINDER_THREADS)
    , mStarvationStartTimeMs(0)
    , mManagesContexts(false)
    , mBinderContextCheckFunc(NULL)
    , mBinderContextUserData(NULL)
    , mThreadPoolStarted(false)
    , mThreadPoolSeq(1)
{
    if (mDriverFD >= 0) {
        // mmap the binder, providing a chunk of virtual address space to receive transactions.
        mVMStart = mmap(0, BINDER_VM_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0); 
        if (mVMStart == MAP_FAILED) {
            // *sigh*
            ALOGE("Using /dev/binder failed: unable to mmap transaction memory.\n");
            close(mDriverFD);
            mDriverFD = -1; 
            mDriverName.clear();
        }   
    }   

    LOG_ALWAYS_FATAL_IF(mDriverFD < 0, "Binder driver could not be opened.  Terminating.");
}

虽然不是很了解C的代码,勉强看出是binder通信是创建虚拟地址出错了,以防万一,找公司驱动工程师看一下是不是binder通信出现问题,驱动的回复是binder通信,需要一块虚拟内存地址,mmap时找不到地址。现在怀疑是系统内存不足,在启动应用时没有足够的地址分配,而这时binder去获取应用的虚拟地址去通信,找不到此应用的虚拟地址,所以出现以上现象。

安卓有自己的内存管理机制,内存不够时,此时 Android 系统使用”LowMemory Killer”实现内存管理机制,即根据程序的重要性来决定 Kill 谁。但是项目的android系统没有执行内存机制,又没有头绪,然后各种百度,也没找到有用的信息,突然想到在设置的开发者选项中有一个限制后台进程数的选项,这个选项默认选择的是标准限制,将其改为限制4个,然后不停的打开应用,系统不报错了,现在怀疑是这个标准限制出现问题了。

设置中限制后台的preference在DevelopmentSettins.java中

 private void writeAppProcessLimitOptions(Object newValue) {
        try {
            int limit = newValue != null ? Integer.parseInt(newValue.toString()) : -1;
            ActivityManager.getService().setProcessLimit(limit);
            updateAppProcessLimitOptions();
        } catch (RemoteException e) {
        }
 }

继续追踪到frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

    @Override
    public void setProcessLimit(int max) {
        enforceCallingPermission(android.Manifest.permission.SET_PROCESS_LIMIT,
                "setProcessLimit()");
        synchronized (this) {
            mConstants.setOverrideMaxCachedProcesses(max);
        }     
        trimApplications();
    }

frameworks/base/services/core/java/com/android/server/am/ActivityManagerConstants.java

    public void setOverrideMaxCachedProcesses(int value) {
        mOverrideMaxCachedProcesses = value;
        updateMaxCachedProcesses();
    }
    private void updateMaxCachedProcesses() {
        CUR_MAX_CACHED_PROCESSES = mOverrideMaxCachedProcesses < 0
                ? MAX_CACHED_PROCESSES : mOverrideMaxCachedProcesses;
        CUR_MAX_EMPTY_PROCESSES = computeEmptyProcessLimit(CUR_MAX_CACHED_PROCESSES);

        // Note the trim levels do NOT depend on the override process limit, we want
        // to consider the same level the point where we do trimming regardless of any
        // additional enforced limit.
        final int rawMaxEmptyProcesses = computeEmptyProcessLimit(MAX_CACHED_PROCESSES);
        CUR_TRIM_EMPTY_PROCESSES = rawMaxEmptyProcesses/2;
        CUR_TRIM_CACHED_PROCESSES = (MAX_CACHED_PROCESSES-rawMaxEmptyProcesses)/3;
    }

标准限制的mOverrideMaxCachedProcesses的值为-1,MAX_CACHED_PROCESSES就限制的进程数,

    private static final int DEFAULT_MAX_CACHED_PROCESSES = 32;
    private static final long DEFAULT_BACKGROUND_SETTLE_TIME = 60*1000;
    private static final long DEFAULT_FGSERVICE_MIN_SHOWN_TIME = 2*1000;
    private static final long DEFAULT_FGSERVICE_MIN_REPORT_TIME = 3*1000;
    private static final long DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME = 1*1000;
    private static final long DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME = 5*1000;
    private static final long DEFAULT_CONTENT_PROVIDER_RETAIN_TIME = 20*1000;
    private static final long DEFAULT_GC_TIMEOUT = 5*1000;
    private static final long DEFAULT_GC_MIN_INTERVAL = 60*1000;
    private static final long DEFAULT_FULL_PSS_MIN_INTERVAL = 10*60*1000;
    private static final long DEFAULT_FULL_PSS_LOWERED_INTERVAL = 2*60*1000;
    private static final long DEFAULT_POWER_CHECK_DELAY = (DEBUG_POWER_QUICK ? 2 : 15) * 60*1000;
    private static final long DEFAULT_WAKE_LOCK_MIN_CHECK_DURATION
            = (DEBUG_POWER_QUICK ? 1 : 5) * 60*1000;
    private static final long DEFAULT_CPU_MIN_CHECK_DURATION
            = (DEBUG_POWER_QUICK ? 1 : 5) * 60*1000;
    private static final long DEFAULT_SERVICE_USAGE_INTERACTION_TIME = 30*60*1000;
    private static final long DEFAULT_USAGE_STATS_INTERACTION_INTERVAL = 24*60*60*1000L;
    private static final long DEFAULT_SERVICE_RESTART_DURATION = 1*1000;
    private static final long DEFAULT_SERVICE_RESET_RUN_DURATION = 60*1000;
    private static final int DEFAULT_SERVICE_RESTART_DURATION_FACTOR = 4;
    private static final long DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN = 10*1000;
    private static final long DEFAULT_MAX_SERVICE_INACTIVITY = 30*60*1000;
    private static final long DEFAULT_BG_START_TIMEOUT = 15*1000;

    // Maximum number of cached processes we will allow.
    public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES;

所以最后的值为DEFAULT_MAX_CACHED_PROCESSES = 32,将32改为10,编译整个项目,不停的打开应用,系统不会报错了。这个应该是系统默认缓存的进程数,32个进程占的内存超过内存的总量,进程数没达到32不会触发内存管理机制,但这时内存又已经溢出了,所以系统报错。

暂时分析如此,如有错误,欢迎提出。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐