Android开发 处理内存申请失败的报错(Failed to allocate a 38189038 byte allocation with 16777216 free bytes and 20MB until OOM)
问题原因
当你在操作图片或者其他大量文件数据时会出现:Failed to allocate a 38189038 byte allocation with 16777216 free bytes and 20MB until OOM 报错.
为什么会出现这个报错?原因很简单.因为一个app的内存只有64MB,而你在操作需要更多内存的文件.这个时候app无法申请到内存就会报这个错误.
解决办法
1.在清单文件中添加 android:largeHeap="true" 属性,将APP的内存从64MB拓展成128MB
<application
android:name=".app.App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="demo"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:largeHeap="true"
tools:replace="android:label">
2.尽量减少使用图片图标,用矢量图代替图标图片
3.尽快的释放一些不需要的使用的内存占用
4.保证app没有内存泄漏
Android开发 处理内存申请失败的报错(Failed to allocate a 38189038 byte allocation with 16777216 free bytes and 20MB until OOM)的更多相关文章
- ClouderaManager启动NodeManager失败!报错Failed to initialize container executor
报错信息: 2016-07-27 10:53:14,102 WARN org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor: ...
- mesos-master启动失败,报错Failed to load unknown flag 'quorum.rpmsave'
[现象] mesos启动失败,查看mesos状态报错: [root@hps102 ~]# systemctl status mesos-master ● mesos-master.service - ...
- Spring Boot 2.1.7 启动项目失败,报错: "Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured."
一开始按照网上的很多解决办法是: 启动类头部声明@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}),但是这样会排除 ...
- openstack 创建虚拟机的时候报错: Failed to allocate the network(s), not rescheduling.].
错误: 实例 "test-gtj" 执行所请求操作失败,实例处于错误状态.: 请稍后再试 [错误: Build of instance 5ea8c935-ee07-4788-823 ...
- python打开文件失败,报错'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence
python3.7,python3.6都存在的问题: 读取的文件编码是utf-8 第1行是空行.#开头都可能会报这个错误: E:\count_packet>python string_count ...
- 【spring cloud】在spring cloud服务中,打包ms-core失败,报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project
在spring cloud服务中,有一个ms-code项目,只为所有的微服务提供核心依赖和工具类,没有业务意义,作为核心依赖使用.所以没有main方法,没有启动类. 在spring cloud整体打包 ...
- Eclipse启动 报错[Failed to load the JNI shared library jvm.dll
准备要做java服务器,在安装开发环境时,启动Eclipse报错[Failed to load the JNI shared library jvm.dll] 研究了下,造成错误的原因是由于eclip ...
- 安卓开发第一记 android stdio 安装后 新建测试项目报错
Failed to resolve:com.android.support:appcompat-v7:报错处理 你在使用android studio时是否也出现过上图的报错,你还在为它的出现烦恼? ...
- Android ADT中增大AVD内存后无法启动:emulator failed to allocate memory 8 (转)
Android ADT中增大AVD内存后无法启动:emulator failed to allocate memory 8http://www.crifan.com/android_emulator_ ...
随机推荐
- NX二次开发-NXOpen中Point3d类型转换成point类型
NX9+VS2012 #include <NXOpen/NXObject.hxx> #include <NXOpen/Part.hxx> #include <NXOpen ...
- centos7.2搭建kubernetes1.5.2+dashboard
一. 简介 近来容器对企业来说已经不是什么陌生的概念,Kubernetes作为Google开源的容器运行平台,受到了大家的热捧.搭建一套完整的kubernetes平台,也成为试用这套平台必须迈过 ...
- SPSS数据记录的选择(Select Cases)
SPSS数据记录的选择(Select Cases) 在数据分析时,有时可能只对某些记录感兴趣.例如,在判别分析时,可能用其中90%的记录数据建立判别函数,用其余10%的记录来考核判别函数.此时,可以通 ...
- hexo next主题深度优化(八),微加速
个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io 通过不断地上网查资料,引用的js.css.图片 ...
- jQuery 快捷操作
快捷操作 1. class属性值操作 $().attr(‘class’,值); $().attr(‘class’); $().removeAttr(‘class’); //删除class的所有属性 ...
- ubuntu 删除 mysql (转)
1 sudo apt-get autoremove --purge mysql-server-5.0 2 sudo apt-get remove mysql-server 3 sudo apt-get ...
- Japan 2005 Domestic Cleaning Robot /// BFS 状压 二进制位运算 结构体内构造函数 oj22912
题目大意: 输入w h,接下来输入h行w列的图 ' . ':干净的点: ' * ' :垃圾: ' x ' : 墙: ' o ' : 初始位置: 输出 清理掉所有垃圾的最短路径长度 无则输出-1 ...
- docker删除常见命令
$ docker stop $(docker ps -a | grep "Exited" | awk '{print $1 }') //停止容器 1b7067e19d6f a840 ...
- asp.net core2.0 依赖注入 AddTransient与AddScoped的区别 - 晓剑 - CSDN博客
原文:asp.net core2.0 依赖注入 AddTransient与AddScoped的区别 - 晓剑 - CSDN博客 原文地址:http://www.tnblog.net/aojiancc2 ...
- 【noi.ac-CSP-S全国模拟赛第三场】#705. mmt
给定数组a[],b[] 求$$c_i=\sum_{j=1}^{i} a_{\left \lfloor \frac{n}{j} \right \rfloor}·b_{i \bmod j}$$ 大概就是对 ...