How to see (approximate) memory usage in a UWP application while running

According to this article, Diagnosing memory problems with the new memory usage tool in Visual Studio :

1. Memory covers on telephone devices . In particular, there are certain memory restrictions for a phone that are applied in an application based on the size of the memory in the device. Allocating more than the specified limit will throw an OutOfMemoryException and cause the application to terminate.

Everything is good and good, and in Visual Studio you can use the Diagnostics tool to see memory usage during development.

Is there a way that a UWP application running on (Windows 10) can get a rough idea of ​​how much memory it consumes? - Ie in the application, not using visual studio.

Update - How I Selected "Answer"

The main thing is that this exposed a huge lack of understanding on my part with regard to memory in general and, in particular, about how modern .net applications consume it. Both of these answers helped me, and although I experimented briefly with the fact that it is difficult to say, either one of them is the correct answer, since I believe that both of them are useful.

In addition, although I appreciate both answers that cite the relevant official documentation, this information is pretty subtle (disrespect for Romasz and Alexay).

In the end, I got a response to Romasz, as the API seems a little deeper.

+5
source share
2 answers

I think you can also use the MemoryManager class. There you can subscribe to events informing about an increase / decrease in the amount of memory, set limits, and also as a check of application memory usage or read reports for the application or for the process :

var appMemory = MemoryManager.AppMemoryUsage; var appMemoryReport = MemoryManager.GetAppMemoryReport(); var processMemoryReport = MemoryManager.GetProcessMemoryReport(); 
+7
source

For UWP applications, there is the ProcessDiagnosticInfo class .

 ProcessMemoryUsageReport mu = ProcessDiagnosticInfo.GetForCurrentProcess().MemoryUsage.GetReport(); 
+4
source

All Articles