Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Windows phone应用程序的内存状态

From Wiki
Jump to: navigation, search
SignpostIcon XAML 40.png
SignpostIcon WP7 70px.png
Article Metadata

WS_YiLunLuo 在 16 Dec 2011 创建
最后由 hamishwillee 在 18 Jul 2013 编辑



如果要测量你的应用程序是如何使用内存并对此作出修改,那么下面的代码将会给你帮助。从根本上说:DeviceStatus允许应用程序来获取设备的信息。 要获得内存的详细信息,那么下面的属性是必须的

  • ApplicationCurrentMemoryUsage 以字节为单位返回当前的内存使用大小
  • ApplicationMemoryUsageLimit 返回你的应用程序在运行时可以分配到的最大内存量。
  • ApplicationPeakMemoryUsage 以字节为单位返回当前应用程序的峰值内存状态。
  • DeviceTotalMemory 以字节为单位返回设备的物理RAM大小。



long totalMemory = DeviceStatus.DeviceTotalMemory;
long currentApplicationMemoryUsage = DeviceStatus.ApplicationCurrentMemoryUsage;
long peakApplicationMemoryUsage = DeviceStatus.ApplicationPeakMemoryUsage;
long applicationMemoryUsageLimit = DeviceStatus.ApplicationMemoryUsageLimit;
totalMemory /= 1024 * 1024;
currentApplicationMemoryUsage /= 1024 * 1024;
peakApplicationMemoryUsage /= 1024 * 1024;

DeviceStatus不仅提供了内存的详细状况,它还提供了DeviceName, DeviceManufacturer, DeviceHardwareVersion等等,同时我们也会看到DeviceExtendedProperties中一些过时的不推荐使用的属性。

DeviceExtendedProperties还有一个额外的属性- DeviceUniqueId,但它不存在于DeviceStatus中,否则我们就能同时使用来获取这些属性值。

Note.pngNote: 在Windows Phone OS 7.1中,大多数DeviceExtendedProperties里的属性是不推荐使用的,相反应该使用DeviceStatus类。

This page was last modified on 18 July 2013, at 06:35.
70 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.