加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 确定在抛出OutOfMemoryException之前可以使用的可用内存

发布时间:2020-12-15 21:48:47 所属栏目:百科 来源:网络整理
导读:在系统本身内存不足之前,我的应用程序的OutOfMemoryException被抛出,如下所述: MSDN Blogs – Out of memory? Easy ways to increase the memory available to your program. When you run your C# application,you might get an OutOfMemoryException thro
在系统本身内存不足之前,我的应用程序的OutOfMemoryException被抛出,如下所述:
MSDN Blogs – Out of memory? Easy ways to increase the memory available to your program.

When you run your C# application,you might get an OutOfMemoryException thrown,even if your machine has lots of memory. […] That 4 Gigs is divided into half: the user application gets the lower half and the OS gets the upper. (This boundary can be changed: see below).

根据请求,我需要可视化我的应用程序可用的内存量和当前使用情况.可以使用Process.GetCurrentProcess()检索当前用法;和其他人,但如何在运行时确定我的应用程序可用的内存?我只是想不通.

解决方法

您可以在大量分配之前使用 MemoryFailPoint进行检查.这并不是您所要求的,但如果您的故障位于特定的已知大分配点,则至少可以让您在发生分配失败时干净利落地处理分配失败.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读