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二次开发-弹出选择文件夹对话框
这个UFUN和NOPEN里没有对应的函数和类,要用C++的方法去做. #include "afxdialogex.h"//弹出选择文件夹对话框头文件 #include " ...
- [NOI.AC] count
思路: 考虑组合数学. 当所求中没有重复的时候,方案数就是\(C_{n + 1}^{k}\) 当有重复的时候... 设相等的数字之间的距离为\(len\) 当取0个数时,方案数就是\(C_{n - 1 ...
- Linux下使用Eclipse 远程调试
1 开启端口 修改/apache-tomcat-7.0.40/bin/catalina.sh 在合适的位置(请自行判断,只要有JAVA_OPTS的设定前后即可)插入下面的设定:UI_DEBUG=&qu ...
- mac的终端运行ifconfig
lo0:loopback回环地址一般是127.0.0.0,loopback指本地环回接口(或地址),亦称回送地址().此类接口是应用最为广泛的一种虚接口,几乎在每台路由器上都会使用. gif0: so ...
- Soldier and Number Game-素数筛
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and giv ...
- map、filter、forEach、reduce数组方法的封装
1.map方法的封装 Array.prototype.mapAlley = function(callback){ //获取调用mapAlley这个方法的数组 let arr = thi ...
- 如何在windows上把你的项目提交到github(转载)
(1)如何在windows上把你的项目提交到githubhttp://michaelye1988.iteye.com/blog/1637951 (2)github错误提示:fatal:remote o ...
- C#枚举转化示例大全,数字或字符串转枚举
本文重点举例说明C#枚举的用法,数字转化为枚举.枚举转化为数字及其枚举数值的判断,以下是具体的示例: 先举两个简单的例子,然后再详细的举例说明: 字符串转换成枚举:DayOfWeek week=(Da ...
- 【POJ】2253 Frogger
= =.请用C++提交.. 如果有朋友能告诉我G++和C++交题什么机制..我感激不尽.G++杀我. 题目链接:http://poj.org/problem?id=2253 题意:青蛙A要去找B约会, ...
- HttpWebRequest 基础连接已经关闭: 接收时发生错误 GetRequestStream 因为算法不同,客户端和服务器无法通信。
在代码行 HttpWebRequest objRequest = (HttpWebRequest)HttpWebRequest.Create(sUrl 前面加上 ServicePointManager ...