
当你在 *** 作图片或者其他大量文件数据时会出现: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)全部内容,希望文章能够帮你解决Android开发 处理内存申请失败的报错(Failed to allocate a 38189038 byte allocation with 16777216 free bytes and 20MB until OOM)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)