Skip to main content
 首页 » 编程设计

c#之如何获取我的应用程序可用的内存量

2024年02月27日30oomusou

我发现我可以通过以下方式读取可用的物理内存 ComputerInfo.TotalPhysicalMemory 属性。 http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.devices.computerinfo.totalphysicalmemory.aspx

但是有什么方法可以找出我实际可用的内存吗? 应用。 例如,如果我的内存不足,我可以使用react。

这可能吗? 或者这只是不好的做法。

提前致谢

请您参考如下方法:

如果您阅读 Eric Lippert article你会看到这个重要的段落:

An “out of memory” error almost never happens because there’s not enough storage available; as we’ve seen, storage is disk space, and disks are huge these days. Rather, an “out of memory” error happens because the process is unable to find a large enough section of contiguous unused pages in its virtual address space to do the requested mapping.

无法知道是否有连续的未使用页面可用。

当你遇到“内存不足”异常时,你能做的最好的事情就是优雅地死去。