程序内存检测
本文參考自:http://www.cnblogs.com/hebeiDGL/p/3410188.html
static System.Windows.Threading.DispatcherTimer dispacherTimer;static string total = "DeviceTotalMemory";static string current = "ApplicationCurrentMemoryUsage";static string peak = "ApplicationPeakMemoryUsage";static long totlaBytes;static long currentBytes;static long peakBytes;public MainPage(){InitializeComponent();checkmemory();}void checkmemory() {dispacherTimer = new System.Windows.Threading.DispatcherTimer();dispacherTimer.Interval = TimeSpan.FromSeconds(2);dispacherTimer.Tick += dispacherTimer_Tick;dispacherTimer.Start();}void dispacherTimer_Tick(object sender, EventArgs e){// 獲取設(shè)備的總內(nèi)存totlaBytes = (long)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue(total);// 獲取應(yīng)用當(dāng)前占用內(nèi)存currentBytes = (long)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue(current);// 獲取內(nèi)存占用的峰值peakBytes = (long)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue(peak);txtMemory.Text = string.Format("當(dāng)前:{0:F2}MB; 峰值:{1:F2}MB; 總:{2:F2}MB;", currentBytes / (1024 * 1024.0), peakBytes / (1024 * 1024.0), totlaBytes / (1024 * 1024.0));}
轉(zhuǎn)載于:https://www.cnblogs.com/defoliate/p/3677765.html
總結(jié)
- 上一篇: SuperSpider——打造功能强大的
- 下一篇: 三星note20u和苹果12promax