DeviceStatus.ApplicationMemoryUsageLimit Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns the maximum amount of memory that your application process can allocate in bytes.

Namespace:  Microsoft.Phone.Info
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)

Syntax

Public Shared ReadOnly Property ApplicationMemoryUsageLimit As Long
public static long ApplicationMemoryUsageLimit { get; }

Property Value

Type: System..::.Int64
Returns Int64.

Remarks

If your application tries to allocate more memory than is available on the device, the application will terminate with an OutOfMemoryException. You can use this property to help prevent that scenario from happening.

Warning

The value returned by this property can vary depending on the type of process that called the property, and the current amount of available memory on the device. For example, the amount of memory that a background agent process can allocate could be different than the amount that a foreground application process can allocate. For this reason, do not assume that your process will always have access to the same amount of memory.

Warning

When called from a Silverlight 8.1 app, this API always returns 0. To manage memory for Silverlight 8.1 apps, use the [https://go.microsoft.com/fwlink/p/?LinkId=394902] class instead.

Examples

The following code example shows how you can use this property, and the ApplicationCurrentMemoryUsage property, to determine the maximum additional amount of memory that your application process can allocate.

long x = DeviceStatus.ApplicationMemoryUsageLimit – DeviceStatus.ApplicationCurrentMemoryUsage;

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Platforms

Windows Phone

See Also

Reference

DeviceStatus Class

Microsoft.Phone.Info Namespace

Other Resources

Device status for Windows Phone 8