[英]UWP: Is there a way to be notified when the app reaches a certain usage of memory?
I am developing a UWP app which could have a fair amount of memory pressure. 我正在开发一个可能会有相当大的内存压力的UWP应用程序。
I want to adapt the memory usage, so that I don't get short of it when I need. 我想调整内存使用量,以便在需要时不会缺少它。
Is there a way inside the App (I am thinking mainly about an event that I can register from my App or MainPage, or something similar...) to get notified when ie the memory usage of the App reached 90% of the allowed value for my App (eg in tablets) or 90% of the available memory of the overall system? 应用程序内部是否存在一种方式(我主要考虑的是我可以从我的应用程序或主页中注册的事件,或类似的东西......),以便在应用程序的内存使用量达到允许值的90%时得到通知对于我的应用程序(例如平板电脑)或整个系统可用内存的90%?
Thank you! 谢谢!
Your best bet for this is the MemoryManager.AppMemoryUsageIncreased event: https://docs.microsoft.com/en-us/uwp/api/windows.system.memorymanager.appmemoryusageincreased 你最好的选择是MemoryManager.AppMemoryUsageIncreased事件: https : //docs.microsoft.com/en-us/uwp/api/windows.system.memorymanager.appmemoryusageincreased
If this isn't granular enough for your purpose, you could monitor MemoryManager.AppMemoryUsage property yourself, relative to the MemoryManager.AppMemoryUsageLimit property 如果这不够精确,您可以自己监视MemoryManager.AppMemoryUsage属性,相对于MemoryManager.AppMemoryUsageLimit属性
https://docs.microsoft.com/en-us/uwp/api/windows.system.memorymanager.appmemoryusage https://docs.microsoft.com/en-us/uwp/api/windows.system.memorymanager.appmemoryusagelimit https://docs.microsoft.com/en-us/uwp/api/windows.system.memorymanager.appmemoryusage https://docs.microsoft.com/en-us/uwp/api/windows.system.memorymanager.appmemoryusagelimit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.