3

I have a live wallpaper application which loads multiple user-selected images as bitmaps. This process is very memory intensive, as multiple bitmaps are loaded. The application crashes on some phones if the live wallpaper is already applied and then also previewed in the live wallpaper picker. I believe this is because a second instance of the renderer is created, which uses twice as much bitmap memory as needed, causing a crash.

How would I stop the preview mode from creating a new instance of the live wallpaper, but instead load the already existing renderer?

shpen
  • 53
  • 5
  • I'm also stuck on this, my live wallpaper works but sometimes it crashes if it's already running. Did you ever find a solution? – Oliver Dixon Aug 09 '12 at 13:07
  • No, I just caught the memory exception and disabled rendering in the preview. I was unable to find a way to share one renderer. – shpen Nov 03 '12 at 08:34

1 Answers1

3

I had the same problem and solved it by making the bitmaps static so that they are shared among the instances. Don't forget to check if a bitmap is null before loading/decoding it to avoid unnecessary processing.

Leo
  • 81
  • 2
  • 6