PeriodicTask WritableBitmap & OutOfMemory exceptions

SpielerB

New member
Jan 27, 2014
7
0
0
Visit site
Hi there,

is it possible to create LiveTiles using a WritableBitmap within a PeriodicTask in Windows Phone 8? I am trying to to display contact photos on my app's LiveTile but got frequent OutOfMemory exceptions in the PeriodicTask while using WritableBitmap. The total available memory seemed to be 11mb, I thought this is the restriction for low memory devices (I tested on a Samsung AtivS), how can I opt for more memory?

Than I thought it might be okay to use the ResourceIntensiveTask instead - haven't tried it out yet - but reading the Microsoft doc, it seems like the ResourceIntensiveTask has the same memory restrictions?

Has anybody experiences on such a topic? Any help would be appreciated!

Thanks a lot & Best regards,

Benjamin
 

nemecek_f

New member
Apr 14, 2013
109
0
0
Visit site
Hello, are you rendering new images? Bunch of apps create tile images with background agents so it should be possible. Maybe your problem lies elsewhere. Loading images into bitmap usually consumes a lot of memory.

As for ResourceIntensiveTask, this one has more strict requirements. It probably runs only if phone battery is in good state and there are also other conditions. I don't know them from memory.
 

SpielerB

New member
Jan 27, 2014
7
0
0
Visit site
Hi!
the method Microsoft.Phone.UserData.Contact.GetPicture returns a stream which I set to the BitmapImage, so yes, I am rendering new images... but I do not see any other possibility to render the Contact.GetPicture stream?!

ResourceIntesiveTask has some restrictions like only if connected to WLAN which does not make any sense in my use case... I just would like to know if this task has the same memory limit? Than I could think about a workaround...

Any other ideas?

BR
Benjamin
 

nemecek_f

New member
Apr 14, 2013
109
0
0
Visit site
Ok, are your rendering that image from one contact or from multiple? If you are using only one contact, you could try to just save the image to Shared/ShellContent without rendering. Here you can find bunch of tips how to limit memory usage when working with images - c# - Windows phone: listbox with images out-of-memory - Stack Overflow Images in Windows Phone are tricky area :)

All types of scheduled agents can use up to 20 MB memory and + 5 MB more if handset is running GDR3. That could be enough. While rendering image in-app I managed to consume 28 MB.
 

SpielerB

New member
Jan 27, 2014
7
0
0
Visit site
Multiple, everything else would have been too easy :cool:

Thanks for the link! I will try out the given tweaks there (nulling ImageSource, etc...) actually I was already calling GC.Collect in between to get more memory.

Still I am surprised: DeviceStatus.ApplicationMemoryUsageLimit returns ~11mb during my debugging session?!

If everything fails, I will pre-create the tile-images while the app is running in foreground and than just set the right one in the periodic task. This would mean that the user has to start the app at least every 2nd or 3rd day... :shocked:
 
Last edited:

Members online

Forum statistics

Threads
323,196
Messages
2,243,432
Members
428,035
Latest member
jacobss