Could not create epoll instance: Too many open files 问题引起的内存泄露

问题:开发的app,在测试环境运行没有问题,但是在预发布环境,每隔3至4分钟就会崩溃,灰常有规律…溃日志如下:

--------- beginning of crash
09-07 10:56:27.755 12156 12156 E AndroidRuntime: FATAL EXCEPTION: main
09-07 10:56:27.755 12156 12156 E AndroidRuntime: Process: com.example.package, PID: 12156
09-07 10:56:27.755 12156 12156 E AndroidRuntime: java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.InputChannel.nativeReadFromParcel(Native Method)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.InputChannel.readFromParcel(InputChannel.java:148)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.InputChannel$1.createFromParcel(InputChannel.java:39)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.InputChannel$1.createFromParcel(InputChannel.java:37)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:68)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:112)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:110)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at com.android.internal.view.IInputMethodManager$Stub$Proxy.startInputOrWindowGainedFocus(IInputMethodManager.java:723)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1301)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.inputmethod.InputMethodManager.onPostWindowFocus(InputMethodManager.java:1549)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3923)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:164)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6600)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
09-07 10:56:27.755 12156 12156 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:821)
09-07 10:56:27.759 12156 12611 F Looper  : Could not create epoll instance: Too many open files
09-07 10:56:27.760 12156 12156 W System.err: java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
09-0    7 10:56:27.761 12156 12156 W System.err:    at android.view.InputChannel.nativeReadFromParcel(Native Method)
09-07 10:56:27.761 12156 12156 W System.err:    at android.view.InputChannel.readFromParcel(InputChannel.java:148)
09-07 10:56:27.761 12156 12156 W System.err:    at android.view.InputChannel$1.createFromParcel(InputChannel.java:39)
09-07 10:56:27.761 12156 12156 W System.err:    at android.view.InputChannel$1.createFromParcel(InputChannel.java:37)
09-07 10:56:27.761 12156 12156 W System.err:    at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:68)
09-07 10:56:27.761 12156 12156 W System.err:    at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:112)
09-07 10:56:27.761 12156 12156 W System.err:    at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:110)
09-07 10:56:27.761 12156 12156 W System.err:    at com.android.internal.view.IInputMethodManager$Stub$Proxy.startInputOrWindowGainedFocus(IInputMethodManager.java:723)
09-07 10:56:27.761 12156 12156 W System.err:    at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1301)
09-07 10:56:27.761 12156 12156 W System.err:    at android.view.inputmethod.InputMethodManager.onPostWindowFocus(InputMethodManager.java:1549)
09-07 10:56:27.761 12156 12156 W System.err:    at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3923)
09-07 10:56:27.761 12156 12156 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:106)
09-07 10:56:27.762 12156 12156 W System.err:    at android.os.Looper.loop(Looper.java:164)
09-07 10:56:27.762 12156 12156 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:6600)
09-07 10:56:27.762 12156 12156 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
09-07 10:56:27.762 12156 12156 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
09-07 10:56:27.762 12156 12156 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:821)
09-07 10:56:27.815 12156 12156 W System.err: java.io.IOException: Cannot run program "cat": error=24, Too many open files
09-07 10:56:27.815 12156 12156 W System.err:    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
09-07 10:56:27.815 12156 12156 W System.err:    at java.lang.Runtime.exec(Runtime.java:692)zhangxs123&@
09-07 10:56:27.816 12156 12156 W System.err:    at java.lang.Runtime.exec(Runtime.java:560)
09-07 10:56:27.816 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.collectMemInfo(CrashHandler.java:286)
09-07 10:56:27.816 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.collectInfo(CrashHandler.java:160)
09-07 10:56:27.816 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.catchCrashException(CrashHandler.java:125)
09-07 10:56:27.816 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.uncaughtException(CrashHandler.java:97)
09-07 10:56:27.816 12156 12156 W System.err:    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
09-07 10:56:27.816 12156 12156 W System.err:    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
09-07 10:56:27.816 12156 12156 W System.err:    at java.lang.Thread.dispatchUncaughtException(Thread.java:1955)
09-07 10:56:27.816 12156 12156 W System.err: Caused by: java.io.IOException: error=24, Too many open files
09-07 10:56:27.816 12156 12156 W System.err:    at java.lang.UNIXProcess.forkAndExec(Native Method)
09-07 10:56:27.816 12156 12156 W System.err:    at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
09-07 10:56:27.817 12156 12156 W System.err:    at java.lang.ProcessImpl.start(ProcessImpl.java:128)
09-07 10:56:27.817 12156 12156 W System.err:    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
09-07 10:56:27.817 12156 12156 W System.err:    ... 9 more
09-07 10:56:27.824 12156 12156 W System.err: java.io.FileNotFoundException: /storage/emulated/0/hbsqjz/crash/crash-2018-09-07-10-56-27.log (Too many open files)
09-07 10:56:27.824 12156 12156 W System.err:    at java.io.FileOutputStream.open0(Native Method)
09-07 10:56:27.824 12156 12156 W System.err:    at java.io.FileOutputStream.open(FileOutputStream.java:287)
09-07 10:56:27.824 12156 12156 W System.err:    at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
09-07 10:56:27.824 12156 12156 W System.err:    at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
09-07 10:56:27.824 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.saveCrashInfo2File(CrashHandler.java:323)
09-07 10:56:27.824 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.catchCrashException(CrashHandler.java:127)
09-07 10:56:27.824 12156 12156 W System.err:    at com.example.package.safe.CrashHandler.uncaughtException(CrashHandler.java:97)
09-07 10:56:27.825 12156 12156 W System.err:    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
09-07 10:56:27.825 12156 12156 W System.err:    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
09-07 10:56:27.825 12156 12156 W System.err:    at java.lang.Thread.dispatchUncaughtException(Thread.java:1955)
09-07 10:56:27.962 12615 12615 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
09-07 10:56:27.963  1149  1149 I /system/bin/tombstoned: received crash request for pid 12156
09-07 10:56:27.964 12615 12615 I crash_dump64: performing dump of process 12156 (target tid = 12611)
09-07 10:56:27.964 12615 12615 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-07 10:56:27.964 12615 12615 F DEBUG   : Build fingerprint: 'xiaomi/whyred/whyred:8.1.0/OPM1.171019.011/V9.5.12.0.OEICNFA:user/release-keys'
09-07 10:56:27.964 12615 12615 F DEBUG   : Revision: '0'
09-07 10:56:27.964 12615 12615 F DEBUG   : ABI: 'arm64'
09-07 10:56:27.964 12615 12615 F DEBUG   : pid: 12156, tid: 12611, name: Thread-70  >>> com.example.package <<<
09-07 10:56:27.964 12615 12615 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
09-07 10:56:27.968 12615 12615 F DEBUG   : Abort message: 'jniInit'
09-07 10:56:27.968 12615 12615 F DEBUG   :     x0   0000000000000000  x1   0000000000003143  x2   0000000000000006  x3   0000000000000008
09-07 10:56:27.968 12615 12615 F DEBUG   :     x4   0000000000000000  x5   0000000000000000  x6   0000000000000000  x7   7f7f7f7f7f7f7f7f
09-07 10:56:27.968 12615 12615 F DEBUG   :     x8   0000000000000083  x9   7e97b88a5f20cc4e  x10  0000000000000000  x11  0000000000000001
09-07 10:56:27.968 12615 12615 F DEBUG   :     x12  ffffffffffffffff  x13  ffffffffffffffff  x14  ff00000000000000  x15  ffffffffffffffff
09-07 10:56:27.968 12615 12615 F DEBUG   :     x16  00000002aed13fa8  x17  00000072b32f964c  x18  0000007230284470  x19  0000000000002f7c
09-07 10:56:27.968 12615 12615 F DEBUG   :     x20  0000000000003143  x21  00000072223e5000  x22  0000007217135588  x23  0000007217135588
09-07 10:56:27.968 12615 12615 F DEBUG   :     x24  0000000000000000  x25  0000007217135588  x26  00000072223e50a0  x27  0000000000000000
09-07 10:56:27.968 12615 12615 F DEBUG   :     x28  0000000000000000  x29  0000007217133850  x30  00000072b32aeeac
09-07 10:56:27.968 12615 12615 F DEBUG   :     sp   0000007217133810  pc   00000072b32aeec8  pstate 0000000060000000
09-07 10:56:28.246 12615 12615 F DEBUG   : 
09-07 10:56:28.246 12615 12615 F DEBUG   : backtrace:
09-07 10:56:28.246 12615 12615 F DEBUG   :     #00 pc 000000000001dec8  /system/lib64/libc.so (abort+104)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #01 pc 0000000000007f20  /system/lib64/liblog.so (__android_log_assert+304)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #02 pc 00000000000156a8  /system/lib64/libutils.so (android::Looper::rebuildEpollLocked()+348)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #03 pc 0000000000015508  /system/lib64/libutils.so (android::Looper::Looper(bool)+236)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #04 pc 000000000011090c  /system/lib64/libandroid_runtime.so (android::NativeMessageQueue::NativeMessageQueue()+160)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #05 pc 000000000011123c  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativeInit(_JNIEnv*, _jclass*)+28)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #06 pc 0000000000622420  /system/framework/arm64/boot-framework.oat (offset 0x622000) (android.os.Binder.clearCallingIdentity [DEDUPED]+144)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #07 pc 000000000054824c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #08 pc 00000000000dcfb4  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+260)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #09 pc 000000000029a474  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #10 pc 0000000000294a64  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+696)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #11 pc 00000000005315c0  /system/lib64/libart.so (MterpInvokeStatic+224)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #12 pc 0000000000539f14  /system/lib64/libart.so (ExecuteMterpImpl+14612)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #13 pc 0000000000274ec8  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #14 pc 000000000027aad0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #15 pc 0000000000294a44  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+664)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #16 pc 0000000000531404  /system/lib64/libart.so (MterpInvokeDirect+304)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #17 pc 0000000000539e94  /system/lib64/libart.so (ExecuteMterpImpl+14484)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #18 pc 0000000000274ec8  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #19 pc 000000000027aad0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #20 pc 0000000000294a44  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+664)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #21 pc 0000000000531404  /system/lib64/libart.so (MterpInvokeDirect+304)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #22 pc 0000000000539e94  /system/lib64/libart.so (ExecuteMterpImpl+14484)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #23 pc 0000000000274ec8  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #24 pc 000000000027aad0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
    09-07 10:56:28.246 12615 12615 F DEBUG   :     #25 pc 0000000000294a44  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+664)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #26 pc 00000000005315c0  /system/lib64/libart.so (MterpInvokeStatic+224)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #27 pc 0000000000539f14  /system/lib64/libart.so (ExecuteMterpImpl+14612)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #28 pc 0000000000274ec8  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #29 pc 000000000027aad0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #30 pc 0000000000294a44  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+664)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #31 pc 00000000005315c0  /system/lib64/libart.so (MterpInvokeStatic+224)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #32 pc 0000000000539f14  /system/lib64/libart.so (ExecuteMterpImpl+14612)
    09-07 10:56:28.246 12615 12615 F DEBUG   :     #33 pc 0000000000274ec8  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #34 pc 0000000000522e1c  /system/lib64/libart.so (artQuickToInterpreterBridge+1052)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #35 pc 000000000055110c  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #36 pc 0000000000547f88  /system/lib64/libart.so (art_quick_invoke_stub+584)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #37 pc 00000000000dcf78  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #38 pc 000000000046c5e8  /system/lib64/libart.so (art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::ArgArray*, art::JValue*, char const*)+100)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #39 pc 000000000046d814  /system/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+836)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #40 pc 00000000004940f8  /system/lib64/libart.so (art::Thread::CreateCallback(void*)+1120)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #41 pc 0000000000067ec4  /system/lib64/libc.so (__pthread_start(void*)+36)
09-07 10:56:28.246 12615 12615 F DEBUG   :     #42 pc 000000000001f2f4  /system/lib64/libc.so (__start_thread+68)
09-07 10:56:29.167  1149  1149 E /system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_05

日志很长,然而看完后,并没有什么乱用。也有去学习内存分析的知识,但是在这里用不上。
通过android profiler查看,发现内存一直有未小幅度增长,增长区域是native,然而自己并没有编写native相关代码,所以这里的问题没办法查看。
继续看logcat日志,确定mina一直抛出连接失败警告,脑洞大开..以此为切入点,关闭mina,再重新启动app,崩溃的现象就没有了。
网上查找mina断链引发的崩溃问题。。。不甚明白。
关闭mina不是解决方案啊…找服务端人员解决了下链接失败的问题,没有mina断链问题候,崩溃现象也就小时了。。。。
最后还是存在疑惑,mina链接失败的位置,有添加try…catch,但还是会导致这种内存溢出崩溃,很费劲,有没有大神站出来解决一下。。。求关注,求科普

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值