可绘制的内存,它是最好有外APK APK内部资源,或者是相同的内存?内存、它是、或者是、资源

2023-09-06 23:37:09 作者:女王不会哭泣

我有绘制大量的图形,并改变他们的应用程序。因为我有很多图形,我以为具有APK,根据需要从互联网上下载外的图像,并保存在文件应用程序文件夹。

但我开始OutOfMemory异常。

现在的问题是:是否Android处理内存不同,如果我从加载APK图形比我加载它从磁盘

code。使用APK:

      

topView.setBackgroundResource(R.drawable.bg);

  

code,如果图像是APK外:

      

绘制对象D = Drawable.createFromPath(将pathName);    topView.setBackgroundDrawable(D);

  

感谢

丹尼尔

解决方案

没有在内部处理它们的相同。最有可能的,你是泄漏的图像,或不清理它们以最快的速度你可以。尝试调用 Bitmap.recycle(); 一旦你用图像做,迫使Android的把它清理干净。

I have an application that draws a lot of graphics and change them. Since I have many graphics, I thought of having the images outside the APK, downloaded from the internet as needed, and saved on the files application folder.

九种电脑变慢的常见症状 原因 以及解决办法 网络 w2sft的博客 CSDN博客

But I started to get outOfMemory exceptions.

The question is: Does android handle memory different if I load a graphic from APK than if I load it from 'disk'?

code using APK:

topView.setBackgroundResource(R.drawable.bg);

code if image is outside APK:

Drawable d = Drawable.createFromPath(pathName); topView.setBackgroundDrawable(d);

Thanks

Daniel

解决方案

No, internally they are handled the same. Most likely, you're leaking the images, or not cleaning them up as quickly as you could. Try calling Bitmap.recycle(); once you're done with an image, to force Android to clean it up.