1

I'm trying to remove the option to enable live tile in my app for users running a low memory device (like the Nokia Lumia 610). I'm using the code below that I got from Microsoft but a few users running Lumia 800 and Focus i917 report that the live tile functionality disappeared after I added this.

What is the proper way of detected a low memory device?

This is the code I'm using that obviously works in the emulator and for most of the users but not for all:

long result = 0;

try
{
    result = (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
}
catch (ArgumentOutOfRangeException)
{
    //The device has not received the OS update, which means the device is a 512-MB device.
}

if (result < 90000000)
{
    //Low memory device
}
Pedro Lamas
  • 7,185
  • 4
  • 27
  • 35
John
  • 681
  • 1
  • 8
  • 20

1 Answers1

5

I use this code. The problem is probably in the constant, mine is from MSDN page about low memory devices: Developing for 256-MB Devices

/// <summary>
/// Flag if device is Low-memory Tango device or not.
/// </summary>
public static bool IsLowMemDevice
{
    get
    {
        if (!isLowMemDevice.HasValue)
        {
            try
            {
                // check the working set limit 
                long result = (long) DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
                isLowMemDevice = result < 94371840L;
            }
            catch (ArgumentOutOfRangeException)
            {
                // OS does not support this call => indicates a 512 MB device
                isLowMemDevice = false;
            }
        }
        return isLowMemDevice.Value;
    }
}
private static bool? isLowMemDevice;
Martin Suchan
  • 10,600
  • 3
  • 36
  • 66
  • Thank you for your help. When debugging I never get a value in isLowMemDevice and the code is never executed. Where should I put the "private static bool? isLowMemDevice;" in my page? – John Oct 17 '12 at 12:14
  • I have it in an AppHelper class, you can then use the AppHelper.IsLowMemDevice property wherever you want. – Martin Suchan Oct 18 '12 at 09:14