android–dalvikvm-heap:73547536字节分配的内存不足

android–dalvikvm-heap:73547536字节分配的内存不足,第1张

概述我释放了每个对象,回收onDestroy()方法中的所有位图:privatevoidunbindDrawables(Viewview){if(view.getBackground()!=null){view.getBackground().setCallback(null);}if(viewinstanceofViewGroup){for(inti=0;i<((ViewGr

我释放了每个对象,回收onDestroy()方法中的所有位图:

     private voID unbindDrawables(VIEw vIEw) {    if (vIEw.getBackground() != null) {    vIEw.getBackground().setCallback(null);    }    if (vIEw instanceof VIEwGroup) {        for (int i = 0; i < ((VIEwGroup) vIEw).getChildCount(); i++) {        unbindDrawables(((VIEwGroup) vIEw).getChildAt(i));        }    ((VIEwGroup) vIEw).removeAllVIEws();    }}@OverrIDeprotected voID onDestroy(){    super.onDestroy();    unbindDrawables(findVIEwByID(R.ID.RootVIEw));            bitmap.recycle();            bitmap=null;    System.gc();}

我已经在每个类onDestroy()方法中完成了这个编码.但我的logcat仍然显示错误如:

            FATAL EXCEPTION: main            java.lang.RuntimeException: Unable to start activity ComponentInfo{}: androID.vIEw.InflateException: Binary XML file line #2: Error inflating class androID.Widget.relativeLayout             androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:1956)             androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)             androID.app.ActivityThread.access0(ActivityThread.java:123)             androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)             androID.os.Handler.dispatchMessage(Handler.java:99)             androID.os.Looper.loop(Looper.java:137)             androID.app.ActivityThread.main(ActivityThread.java:4424)             java.lang.reflect.Method.invokeNative(Native Method)             java.lang.reflect.Method.invoke(Method.java:511)        com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)        com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:551)             dalvik.system.NativeStart.main(Native Method)           Caused by: androID.vIEw.InflateException: Binary XML file line #2: Error inflating class androID.Widget.relativeLayout           androID.vIEw.LayoutInflater.createVIEw(LayoutInflater.java:606)                com.androID.internal.policy.impl.PhoneLayoutInflater.onCreateVIEw(PhoneLayoutInflater.java:56)            androID.vIEw.LayoutInflater.onCreateVIEw(LayoutInflater.java:653)            androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:678)            androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:466)            androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:396)             androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:352)           com.androID.internal.policy.impl.PhoneWindow.setContentVIEw(PhoneWindow.java:251)           androID.app.Activity.setContentVIEw(Activity.java:1835)           androID.app.Activity.performCreate(Activity.java:4465)          androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)          androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:1920)          ... 11 more          Caused by: java.lang.reflect.InvocationTargetException          java.lang.reflect.Constructor.constructNative(Native Method)          java.lang.reflect.Constructor.newInstance(Constructor.java:417)          androID.vIEw.LayoutInflater.createVIEw(LayoutInflater.java:586)        ... 23 more              Caused by: java.lang.OutOfMemoryError              androID.graphics.Bitmap.nativeCreate(Native Method)              androID.graphics.Bitmap.createBitmap(Bitmap.java:605)              androID.graphics.Bitmap.createBitmap(Bitmap.java:551)              androID.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)              androID.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)              androID.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)              androID.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)          androID.graphics.drawable.Drawable.createFromresourceStream(Drawable.java:773)           androID.content.res.Resources.loadDrawable(Resources.java:1935)           androID.content.res.TypedArray.getDrawable(TypedArray.java:601)           androID.vIEw.VIEw.<init>(VIEw.java:2785)            androID.vIEw.VIEw.<init>(VIEw.java:2722)            androID.vIEw.VIEwGroup.<init>(VIEwGroup.java:379)           androID.Widget.relativeLayout.<init>(relativeLayout.java:174)          ... 26 more

解决方法:

标题说明了一切 – 你试图为一个图像一次分配73兆字节的堆.仅此一项就超过了大多数现代设备上可用的堆大小 – 64兆字节.您需要找到一种方法来使用重要的小图像.

总结

以上是内存溢出为你收集整理的android – dalvikvm-heap:73547536字节分配的内存不足全部内容,希望文章能够帮你解决android – dalvikvm-heap:73547536字节分配的内存不足所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1114395.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存