问题原因

  当你在操作图片或者其他大量文件数据时会出现: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)的更多相关文章

  1. ClouderaManager启动NodeManager失败!报错Failed to initialize container executor

    报错信息: 2016-07-27 10:53:14,102 WARN org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor: ...

  2. mesos-master启动失败,报错Failed to load unknown flag 'quorum.rpmsave'

    [现象] mesos启动失败,查看mesos状态报错: [root@hps102 ~]# systemctl status mesos-master ● mesos-master.service - ...

  3. 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}),但是这样会排除 ...

  4. openstack 创建虚拟机的时候报错: Failed to allocate the network(s), not rescheduling.].

    错误: 实例 "test-gtj" 执行所请求操作失败,实例处于错误状态.: 请稍后再试 [错误: Build of instance 5ea8c935-ee07-4788-823 ...

  5. 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 ...

  6. 【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整体打包 ...

  7. Eclipse启动 报错[Failed to load the JNI shared library jvm.dll

    准备要做java服务器,在安装开发环境时,启动Eclipse报错[Failed to load the JNI shared library jvm.dll] 研究了下,造成错误的原因是由于eclip ...

  8. 安卓开发第一记 android stdio 安装后 新建测试项目报错

    Failed to resolve:com.android.support:appcompat-v7:报错处理   你在使用android studio时是否也出现过上图的报错,你还在为它的出现烦恼? ...

  9. Android ADT中增大AVD内存后无法启动:emulator failed to allocate memory 8 (转)

    Android ADT中增大AVD内存后无法启动:emulator failed to allocate memory 8http://www.crifan.com/android_emulator_ ...

随机推荐

  1. Python的变长参数

    Python的变长参数 def foo1(*args): for arg in args: print arg def foo2(**kargs): for key in kargs: print k ...

  2. union, enum, and struct, 以及结构填充和位字段实现。

    Table 4-9 Compiler storage of data objects by byte alignment Type Bytes Alignment char, bool, _Bool ...

  3. Day 12 :迭代器与生成器

    可迭代:在Python中如果一个对象有__iter__( )方法,则称这个对象是可迭代的(Iterable): 其中__iter__( )方法的作用是让对象可以用for ... in循环遍历,列表Li ...

  4. 利用zk客户端删除solr shard

    进入zk客户端 ./bin/zkCli.sh -server ip:2181 显示所有的内容: ls / 删除数据: rmr /filename path

  5. .net 超链接传值,传过去始终是null

    今天做了一个删除功能,通过点击列表中的删除超链接,通过get请求,跳转到一个处理程序执行删除操作 . 因为不熟悉各种报错 , <%="<td> <a class='d ...

  6. iOS逆向系列-动态调试

    Xcode调试App原理 Mac安装了Xcode Xcode的安装包中包含了debugserver 可执行类型的Mach-O文件,iPhone第一次连接Xcode调试会将Xcode中的debugser ...

  7. iOS开发系列-Shell脚本生成IPA

    概述 在公司开发到了测试阶段需要频繁打包交付给测试,看似简单的工作,重复的流程总是感觉不是那么好,我们可以借助苹果提供的编译指令编译项目. 自动化脚本编译打包IPA 常见的iOS项目就是基于xcode ...

  8. Ip HostName查询

    https://iplist.cc/api // 在线ip hostname查询

  9. pd.Panel转化成json,然后再还原回来

    在使用tornado的write时候有一个需求,是将panel转化成json;而接收端再将json还原成panel格式. 尝试了很久,终于实现了. panel1 =pd.Panel({"on ...

  10. C# - Finalize 和 Dispose

    重要: https://www.cnblogs.com/Jessy/articles/2552839.html https://blog.csdn.net/daxia666/article/detai ...