问题描述
根据使用Visual Studio中的新内存使用工具诊断内存问题:
很好,在Visual Studio中,您可以使用诊断工具查看开发期间的内存使用情况.
All well and good, and in Visual Studio you can use the Diagnostics tool to see memory usage during development.
在(Windows 10)手机上运行的UWP应用程序是否可以通过某种方式大致了解它消耗了多少内存? - IE.而不是利用Visual Studio.
Is there any way a UWP app running on a (Windows 10) phone can get an approximate idea of how much memory it's consuming? - I.e. within the app, not by leveraging visual studio.
更新-我如何选择答案"
关键是,这暴露了我对总体内存(尤其是现代.net应用程序如何使用内存)的大量了解.这两个答案都对我有帮助,即使我短暂地尝试了这两个答案,也很难说其中一个是正确的答案,因为我发现这两个都是有用的.
The key thing is that this has exposed a massive lack of understanding on my part regarding memory in general, and specifically how modern .net apps consume it. Both of these answers were of help to me, and even though I have experimented briefly with both its hard to say either one of them is the right answer as I'm finding both of them useful.
尽管我很欣赏与适当的官方文档相关的两个答案,但信息非常少(不尊重Romasz& Alexej).
Also whilst I appreciate both the answers linking to the appropriate official documentation, that information is pretty thin (no disrespect to Romasz & Alexej).
最后,我将Romasz的答案授予了API,因为它看起来更深了.
In the end I've awarded the Answer to Romasz as the API seems a little deeper.
推荐答案
我认为您也可以使用类.在那里,您可以订阅通知有关内存增加/减少,设置限制以及或阅读报告或:
I think you can also make use of MemoryManager class. There you can subscribe to events informing about increase/decrease of memory, set limits, as well as check memory usage of app or read reports for app or for process:
var appMemory = MemoryManager.AppMemoryUsage;
var appMemoryReport = MemoryManager.GetAppMemoryReport();
var processMemoryReport = MemoryManager.GetProcessMemoryReport();
这篇关于如何在UWP App运行时查看(大约)内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!