sabato 8 settembre 2012

Windows Phone - Low memory devices

SDK 7.1.1 includes features specifics to developing for 256MB devices (Nokia Lumia 610 and others).

Low memory devices have some limitations, then you need to check the memory size and if needed, disable some features to target the largest possible market.

First, you need this MemoryHelper:
public static class MemoryHelper
{
 public static bool IsLowMemDevice { get; set; }

 static MemoryHelper()
 {
   try
   {
     Int64 result = (Int64)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
    if (result < 94371840L) IsLowMemDevice = true; else IsLowMemDevice = false;
   }
   catch (ArgumentOutOfRangeException)
   {
     //windows phone OS not updated, then 512mb
     IsLowMemDevice = false;
   }
 }
}

Now you can easy detect device type:
if (MemoryHelper.IsLowMemoryDevice)
 // do some work


Tips:
  • PeriodicTask and ResourceIntensiveTask classes are not supported to 256MB phones. This background agents throw an exception if you try to schedule them on this devices.
  • Check your app with Windows Phone Memory Profiler (it is included in VS2010).
  • Use WebBrowserTask instead of the <WebBrowser /> control to display web pages.
  • Use BingMapsTask instead <Map /> control.
  • Consider to reduce image quality and reduce the number of the animations.
  • Avoid long lists of data. The best practice is to use data virtualization.
  • Consider to disable page transitions.
  • Remember to test your application with all two emulators!

Nessun commento:

Posta un commento