Throwing OutOfMemoryError “Could not allocate JNI Env“

09-09 15:28:57.588 7460-7471/com.moreunion.zhenghao I/art: Background sticky concurrent mark sweep GC freed 74917(4MB) AllocSpace objects, 15(580KB) LOS objects, 7% free, 59MB/64MB, paused 6.228ms total 59.379ms

07-22 11:55:26.373 17580 17590 I art : Background sticky concurrent mark sweep GC freed 1047697(16MB) AllocSpace objects, 0(0B) LOS objects, 31% free, 29MB/43MB, paused 4.934ms total 159.085ms
1207-22 11:55:26.377 17580 17862 E art : ashmem_create_region failed for 'indirect ref table': Bad file descriptor
1307-22 11:55:26.377 17580 17862 W art : Throwing OutOfMemoryError "Could not allocate JNI Env"
1407-22 11:55:26.387 17580 17580 I MainView: updateTMSIList
1507-22 11:55:26.370 17862 17862 W pool-6-thread-1: type=1400 audit(0.0:133498): avc: denied { read } for name="mem" dev="debugfs" ino=1015374 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debugfs:s0 tclass=file permissive=0
1607-22 11:55:26.370 17862 17862 W pool-6-thread-1: type=1400 audit(0.0:133499): avc: denied { read } for name="mem" dev="debugfs" ino=1015374 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debugfs:s0 tclass=file permissive=0

Throwing OutOfMemoryError “Could not allocate JNI Env”

可以导致OOM的原因有以下几种:

文件描述符(fd)数目超限,即proc/pid/fd下文件数目突破/proc/pid/limits中的限制。可能的发生场景有:
短时间内大量请求导致socket的fd数激增,大量(重复)打开文件等
线程数超限,即proc/pid/status中记录的线程数(threads项)突破/proc/sys/kernel/threads-max中规定的最大线程数。可能的发生场景有:
app内多线程使用不合理,如多个不共享线程池的OKhttpclient等等
传统的java堆内存超限,即申请堆内存大小超过了 Runtime.getRuntime().maxMemory()
(低概率)32为系统进程逻辑空间被占满导致OOM.
其他

可以利用linux的inotify机制进行监控:

watch /proc/pid/fd来监控app打开文件的情况,
watch /proc/pid/task来监控线程使用情况

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值