Probably most of you have read Performance and Resource Management part of Windows Phone 7 Application Certification Requirements v1.4 document concerning requirements to memory consumption. In particular, there is a sentence regarding low memory devices (which have only 256 MB of RAM installed): “An application must not exceed 90 MB of RAM usage, except on devices that have more than 256 MB of memory”. In this short post I will describe how to detect such devices.

Basically, we need to detect low memory devices to determine what amount of memory is at our disposal and take advantage of it. For example, we can show high quality images on devices, which have more than 256 MB of memory installed and low quality images (i.e in Panorama control) for other devices.

Detecting and simulating low memory devices

To determine a total amount of available memory you need to use DeviceExtendedProperties class with GetValue method and pass “DeviceTotalMemory” key there. That method will return an amount of memory in bytes. This number should not be greater than 256 Megabytes (268435456 Bytes) for low memory devices. To simulate such device in emulator I will simply use a boolean variable (true – for low memory device, false – for other devices).

Memory Consumption

According to Windows Phone 7 Application Certification Requirements document we should use “ApplicationPeakMemoryUsage” key for DeviceExtendedProperties to query the peak of memory usage. There is a nice tutorial on MSDN of that process. Here is the code I use for this purpose: