Live Wallpaper OutOfMemory Error when I have more than 30 frames?

Only create one bitmap and reload each png each time you draw your canvas. For example create a simple routine that will reload each image into the same bitmap allocation. I would also suggest that you convert the png files into jpg files, as png are a lossless format.

With jpg you can compress each frame slightly public void updateBG() { idx += 1; if (idx == NUM_RES) {idx = 0;} switch (bgcycle) { case 0: myBg = BitmapFactory. DecodeResource(getResources(),R.drawable. Frame1); break; case 1: myBg = BitmapFactory.

DecodeResource(getResources(),R.drawable. Frame2); break; case 2: myBg = BitmapFactory. DecodeResource(getResources(),R.drawable.

Frame3); break; case etc.... }} Or I guess you could use this if you want to link to the bootanimation int id = res. GetIdentifier("boot_00" + (100 + (idx + 1)), "drawable", "com.androidnetwork. Animlivewp"); myBg = BitmapFactory.

DecodeResource(res, id) Then in your DrawAnim code just updateBG(); c. DrawBitmap(myBg, mMatrix, null).

Only create one bitmap and reload each png each time you draw your canvas. For example create a simple routine that will reload each image into the same bitmap allocation. I would also suggest that you convert the png files into jpg files, as png are a lossless format.

With jpg you can compress each frame slightly. Public void updateBG() { idx += 1; if (idx == NUM_RES) {idx = 0;} switch (bgcycle) { case 0: myBg = BitmapFactory. DecodeResource(getResources(),R.drawable.

Frame1); break; case 1: myBg = BitmapFactory. DecodeResource(getResources(),R.drawable. Frame2); break; case 2: myBg = BitmapFactory.

DecodeResource(getResources(),R.drawable. Frame3); break; case etc.... }} Or I guess you could use this if you want to link to the bootanimation int id = res. GetIdentifier("boot_00" + (100 + (idx + 1)), "drawable", "com.androidnetwork.

Animlivewp"); myBg = BitmapFactory. DecodeResource(res, id); Then in your DrawAnim code just updateBG(); c. DrawBitmap(myBg, mMatrix, null).

Android.graphics.Bitmap. CreateScaledBitmap(Bitmap. Java:340) means, that Android generates a new Bitmap because you didn't use the drawable-*dpi folders correctly... that can double your needed memory usage.

Back at my last company, where I was working on a mobile platform, we were having some fairly serious performance issues. We did a fair amount of investigation, but we generally seeing that just everything was running slow and were having trouble determining why. Eventually we went to the chipset vendor for help on why things were running slow.

After some time, they came back with the answer: "you are executing too much code. " There is a certain truth to that. And a similar answer is probably appropriate here: you are using too much memory.

You just need to reduce the number or size of bitmaps you are using.

You can't load so many bitmap into memory. You can load limit number bitmap into memory, and when It is need to show other picture. You can free some memory with bitmap's recycle() method, and create new bitmap.

If you wait the GC to garbage collection, the memory is already not enough. The key point is don't load too many bitmap and recycle() when not show in view.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions