安卓报错E/EGL_adreno: tid 3927: eglSurfaceAttrib(1334): error 0x3009 (EGL_BAD_MATCH)

系列文章

提示:转到安卓学习专栏,观看更多内容!
点我直达–>安卓学习专栏


1.报错效果

E/EGL_adreno: tid 3927: eglSurfaceAttrib(1334): error 0x3009 (EGL_BAD_MATCH)

java.lang.OutOfMemoryError: Failed to allocate a 146313228 byte allocation with 16777216 free bytes and 115MB until OOM
在这里插入图片描述


2.报错原因

说明:我们的安卓项目的内存溢出了,我猜测的原因可能是分辨率的区别导致项目内容内存溢出,或是要加载的内容太多了(图片等资源)
尤其是在列表中加载很多数据的控件有自定义图片。


3.解决方法

原来的代码:

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyFourth"
        >
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name=".service.MusicService"/>
    </application>

修改后的代码:
<application标签下新增了

android:largeHeap="true"
android:hardwareAccelerated="false"

完整修改

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyFourth"
        
        android:largeHeap="true"
        android:hardwareAccelerated="false"

        >
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name=".service.MusicService"/>
    </application>
android:hardwareAccelerated="true"

一个应用如果使用了largeHeap,会请求系统为Dalvik虚拟机分配更大的内存空间。使用起来也很方便,只需在manifest文件application节点加入android:largeHeap=“true”即可。

android:hardwareAccelerated="false" 

默认是true会启动硬件加速但是会,占用内存


总结

大家喜欢的话,给个👍,点个关注!继续跟大家分享敲代码过程中遇到的问题!


  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

发现你走远了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值