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_ ...
随机推荐
- 8.RabbitMQ 消息传递Java对象
通过消息服务器传递Java对象,Java类必须实现序列化接口,可以把Java对象转化为字节数组,从消费者或生产者传递到另外一个JVM中,一定需要两个JVM共享这个类,比如是UserInfo类. 1 ...
- (转)AttributeError: module 'tkinter' has no attribute 'messagebox'
AttributeError: module 'tkinter' has no attribute 'messagebox' improt tkinter from tkinter import * ...
- 4-MySQL高级-事务-提交(3)
提交 为了演示效果,需要打开两个终端窗口,使用同一个数据库,操作同一张表 step1:连接 终端1:查询商品分类信息 select * from goods_cates; step2:增加数据 终端2 ...
- iOS开发系列-打印内存地址
打印内存地址 基本数据类型 定义一个基本数据类型,会根据变量类型分配对应的内存空间.比如定义一个int类型的变量a. int a = 10; 内存如下 输入变量a在内存中内存地址 NSLog(@&qu ...
- shell 命令 用户管理
1. 查看保存用户相关信息的文件 [ cat /etc/passwd ] [linux : x : 1000 : 1000 : linux,,, : ...
- Redis的持久化和主从复制机制
Redis持久化 Redis 提供了多种不同级别的持久化方式: RDB 持久化可以在指定的时间间隔内生成数据集的时间点快照(point-in-time snapshot) AOF 持久化记录服务器执行 ...
- 实现虚拟机VMware上Linux与本机windows互相复制与粘贴的问题
解决方法:只需要在Linux系统中安装一个vmware-tools的工具 1.选择虚拟机菜单,有安装vmware tools 工具的选项 点击之后,在Linux的桌面下会出现 VMwareTools. ...
- thinkphp5+GatewayWorker+Workerman
项目地址 ttps://www.workerman.net/workerman-chat thinkphp5+GatewayWorker+Workerman聊天室,可以多人聊天,指定某个人进行聊天, ...
- 【JZOJ2867】Contra
description 偶然间,chnlich 发现了他小时候玩过的一个游戏"魂斗罗",于是决定怀旧.但是这是一个奇怪的魂斗罗 MOD. 有 N 个关卡,初始有 Q 条命. 每通过 ...
- Mysq 列中存储json格式根据key取value
SELECT DISTINCT (SUBSTRING_INDEX( REPLACE ( 列名称, CONCAT( SUBSTRING_INDEX( 列名称, '"key名称":', ...