我有绘制大量的图形,并改变他们的应用程序。因为我有很多图形,我以为具有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.
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.