在请求网络数据或者照片时,数据过大会报错:java.lang.OutOfMemoryError: Failed to allocate a 8294412 byte allocation with 2103464 free bytes and 2MB until OOM
解决方法:
1.拓展APP的内存,在清单文件中添加 android:largeHeap=“true” 属性

 <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        **android:largeHeap="true"**
        android:theme="@style/AppTheme">

2.尽量减少使用图片图标,用矢量图代替图标图片

3.尽快的释放一些不需要的使用的内存占用

4.保证app没有内存泄漏

我使用的第一种方法
参考此链接

Logo

鸿蒙生态一站式服务平台。

更多推荐