0

Developing a JavaScript UWP app on Xbox and I would like to know how can I get CPU and memory usage information

I found this API, Windows.System.Diagnostics.ProcessCpuUsage

but the getReport method is not defined as claimed by Microsoft documentation

https://learn.microsoft.com/en-us/uwp/api/windows.system.diagnostics.processcpuusage

Any help would be greatly appreciated

Leo Teng
  • 93
  • 5
  • 2
    There are new UWP APIs in the Fall Creators Update - take a look at this: https://blogs.windows.com/buildingapps/2017/06/28/uwp-app-diagnostics/ – Stefan Wick MSFT Oct 26 '17 at 19:50
  • @StefanWickMSFT Useful information! Good to know it. It's new feature for UWP. You could make an answer here. – Bite Nov 01 '17 at 07:59

2 Answers2

0

With the Windows 10 Fall Creators Update 1709 (build 16299 and later) we have added a number of new diagnostics APIs to the UWP API surface to support scenarios like this. Please be sure to install and target the SDK version 16299 (or later). Here is a related blog post:

https://blogs.windows.com/buildingapps/2017/06/28/uwp-app-diagnostics/

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
0

I thought I'd add a quick code snippet here to reflect the JavaScript part of the question:

Keep in mind this is only here as a jump-start for anyone trying to get a memory report for your app as it's running from within JS. This is only example code and not terribly fault-tolerant.

Windows.System.AppDiagnosticInfo.requestInfoAsync().then((allProc) => { 
  let proc        = allProc[0];
  let allGroups   = proc.getResourceGroups();
  let procGroup   = allGroups[0];
  let memReport   = procGroup.getMemoryReport();
  console.log(memReport);
  console.log(
    `   [${memReport.commitUsageLevel}] : commitUsageLevel \n` +
    `   [${memReport.commitUsageLimit}] : commitUsageLimit \n` +
    `   [${memReport.privateCommitUsage}] : privateCommitUsage \n` +
    `   [${memReport.totalCommitUsage}] : totalCommitUsage \n`
  )
});
bladnman
  • 2,591
  • 1
  • 25
  • 20
  • If you are going to have this in code that would run anywhere that `Window` is not available you will want to put all of this kind of stuff into a proper try/catch block. – bladnman Nov 10 '18 at 22:46