Question: I have a fairly simple question that I can't answer my self.. Also Google and StackOverflow provided no results :(.

I want my DecodePixelHeight of my BitmapImage to be depended on the amount of RAM the device has. If the device has 512 MB then the DecodePixelHeight should be lower than 1GB and 2GB. I do this because I'm struggling with memory issues.

How do I recognize a low-end device with 512 MB on Windows Phone 8.1 (Universal App)?

Kind regards,
Niels

Answer: 
Below is an excerpt from [this page](http://msdn.microsoft.com/en-us/library/windows/apps/ff941122(v=vs.105).aspx)

> 
> As you develop your app, you can use the **`ApplicationCurrentMemoryUsage`** and **`ApplicationPeakMemoryUsage`** properties to monitor memory usage, and the **`DeviceTotalMemory`** and **`ApplicationMemoryUsageLimit`** properties to determine device and app memory limits. It is not necessary to check the memory usage of your app at extremely small intervals. It is sufficient to occasionally check peak memory usage. If you find that the peak memory usage value crosses the allowable threshold, as described in section 5.2 of Technical certification requirements for Windows Phone, you may choose to monitor memory usage more finely in order to help diagnose the problem.
> 
> 
> 

Specifically, the [`DeviceTotalMemory`](http://msdn.microsoft.com/en-us/library/windows/apps/microsoft.phone.info.devicestatus.devicetotalmemory(v=vs.105).aspx) property should allow you to conditionally perform some task based on the RAM of the device. 

The [`ApplicationMemoryUsageLimit`](http://msdn.microsoft.com/en-us/library/windows/apps/microsoft.phone.info.devicestatus.applicationmemoryusagelimit(v=vs.105).aspx) might be more appropriate considering its purpose, but note that the value it returns will never be 512MB or 1GB, but on 512MB devices it would be *much* lower than on 1GB devices, which you can use for this purpose.

The documentation for [DeviceStatus](http://msdn.microsoft.com/en-us/library/windows/apps/microsoft.phone.info.devicestatus(v=vs.105).aspx) on the MSDN may also provide more insight into this topic.

```
var deviceTotalMemory = Microsoft.Phone.Info.DeviceStatus.DeviceTotalMemory;
var memoryUsageLimit = Microsoft.Phone.Info.DeviceStatus.ApplicationMemoryUsageLimit;

```
Take a look at this article on MSDN

[Developing apps for lower-memory phones for Windows Phone 8](http://msdn.microsoft.com/en-us/library/windows/apps/hh855081(v=vs.105).aspx)

One of the topics is relating to Application Memory limits (allocated by the OS). I think that is the value you should be more worried about, not necessarily the physical memory of the device.

> 
> **Checking the app memory limits of the device**
> 
> 
> With Windows Phone SDK 8.0 or Windows Phone SDK 7.1.1 Update, you can
>  check the memory working set limit of the device hosting your app and
>  Then you can disable some features of your app if you know they aren’t
>  supported or are memory-intensive. To check the memory working set
>  limit, you call the GetValue(String) methodand pass
>  ApplicationWorkingSetLimit for the propertyName parameter. The
>  following code shows how to do this. C#
> 
> 
> 

```
// Place call in a try block in case the user 
// is not running a version of the Windows Phone OS 
// that supports this method call.
try
{
  long result =  
    (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
}
catch (ArgumentOutOfRangeException)
{
  // The device does not support querying for this value. This occurs
  // on Windows Phone OS 7.1 and older phones without OS updates.
}

```

There is a table that shows you how the memory limits should relate to the physical memory of the device.

Also, take a look at this article: [App memory limits for Windows Phone 8](http://msdn.microsoft.com/en-us/library/windows/apps/jj681682%28v=vs.105%29.aspx)