简体   繁体   English

UWP:有什么方法可以在应用达到特定的内存使用时收到通知吗?

[英]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.

相关问题 当用户在wxStyledTextCtrl中进行更改时,是否有一种通知方式? - Is there a way to be notified when the user makes changes in a wxStyledTextCtrl? 当UIImageView到达特定位置时,如何触发事件? - How do I trigger an event when a UIImageView reaches a certain location? 流星:有一种方法可以在模板取下dom时得到通知? - Meteor: Is there a way to be notified when a template is take off the dom? Task.Status更改为正在运行时,是否有一种通知方式? - Is there a way to be notified when Task.Status changes to running? 有什么方法可以在订阅某个活动/代表时收到通知? - Any way to be notified when something subscribes to an event / delegate? 在 F# 中,当任务完成时获得通知的最佳方式是什么? - what is the best way to get notified when a task finishes, in F#? 如何在前台应用程序切换时收到通知 - How to get notified when foreground application switches 当听众退订时,我可以收到通知吗? - Can I be notified when a listener unsubscribes? 部署智能合约时如何获得通知 - How to get notified when smart contract is deployed 在c#中更改日期时间时收到通知 - Getting notified when the datetime changes in c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM