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: 
MS doesn't provide exact method to find the amount of device RAM, but I found the solution myself. I'm telling you what I did to write app code according to device RAM. 

```
private void deviceMemory()
    {
        var memoryLimit = Windows.System.MemoryManager.AppMemoryUsageLimit;
        memoryLimit = (memoryLimit / 1024) / 1024;
        Debug.WriteLine("Device Memory Limit: "+memoryLimit+"MB");
    }

```

It is not what you were expecting but it's always better to have something than nothing. After finding device memory limit I can easily write app code accordingly.

![Memory caps table](https://i.stack.imgur.com/cIMiD.jpg)
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;

```