0
点赞
收藏
分享

微信扫一扫

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

祈澈菇凉 2022-01-08 阅读 143

步骤

系列文章

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


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会启动硬件加速但是会,占用内存


总结

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


举报
0 条评论