Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the amount of RAM (512 mb, 1GB, 2GB) of the device in Windows Phone 8.1 (Universal)?

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

like image 792
Niels Avatar asked Aug 15 '14 21:08

Niels


People also ask

Can I Update my Windows Phone 8.1 to 10?

The Windows Phone 8.1 to Windows 10 Mobile upgrade uses an "opt-in" or "seeker" model. An eligible device must "opt-in" to be offered the upgrade. For consumers, the Windows 10 Mobile Upgrade Advisor app is available from the Windows Store to perform the opt-in.

Can you still use a Windows phone?

End of support means experiences with Xbox related features will have limited to no functionality. In addition, earning achievements through Windows Phone devices will be turned off starting May 16, 2022.

How do I install upgrade Advisor?

To upgrade to Windows 10, first download Windows 10 Upgrade Advisor then launch the application. First enable the app to check if your phone is ready for upgrade. Then make sure that you have installed all Windows updates before you proceed with Windows 10 Upgrade.


2 Answers

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

like image 81
Rich_Ric Avatar answered Nov 03 '22 01:11

Rich_Ric


Below is an excerpt from this page

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 property should allow you to conditionally perform some task based on the RAM of the device.

The ApplicationMemoryUsageLimit 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 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;
like image 38
Joshua Shearer Avatar answered Nov 03 '22 01:11

Joshua Shearer