有50%的可用内存时系统内存不足异常?! [英] system out of memory exception while having 50% of the ram is available?!

查看:100
本文介绍了有50%的可用内存时系统内存不足异常?!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用共享类(如下面所示)或作为实体POCO对象将某些表缓存到内存中.我都尝试过.

 http://blogs.msdn.com/b/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer -to-physical-memory.aspx  

在文章中,他说这对64位计算机应该不是问题,但是我的两台计算机都是64位.它是怎么发生的?如何通过在VB或C#中设置内容或对代码进行编码来管理内存?

当我禁用名为启用Visual Studio托管过程"的选项时,它开始更频繁地发生.可能与此有关吗?

感谢您的建议.


"调试的难度是一开始编写代码的两倍.因此,如果您尽可能聪明地编写代码,那么根据定义,您就不够聪明,无法对其进行调试."


解决方案

您是否为X86编译了该代码,然后将其编译到了任何CPU或X64

在VB2010项目中->项目属性->编译->高级编译器设置选项

在VB2012中,它将更改为直接在编译中


Hi,

I am caching some of my tables into memory using shared class like show below or as entity POCO object. I tried both of them.

    Public Shared Function CacheDT() As cacheDS.CacheDataTable
        If _CacheDT Is Nothing Then
            Dim myCacheTableAdapter As New cacheDSTableAdapters.CacheTableAdapter
            _CacheDT = myCacheTableAdapter.GetData()
        End If
        Return _CacheDT
    End Function

there are plenty of tables which arent changed frequently in my DB. that's why i am caching about 2 GB of data in the memory. my developer machine has 16 gb ram and webserver has 64 gb ram. I am getting system out of memory exception altougt physical memory usage isnt even reaching 8 gb. I found that nice article explaining me it is nothing to do with physical memory but addressing fact http://blogs.msdn.com/b/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer-to-physical-memory.aspx

Indeed in the article he says it shouldnt be a problem with 64bit machine but my both machines are 64. how does it occur? how can I manage my memory by setting up something or coding something in VB or C#? 

EDIT: It started happening more often when I disabled option called "Enable the Visual Studio hosting process". can it be something related to that?

thanks for suggestion.


"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."


解决方案

Did you compile for X86 do it then to any CPU or X64 

In VB2010 Project -> Project Properties -> Compile -> Advanced compiler settings options 

In VB2012 this will be changed to be direct in Compile


这篇关于有50%的可用内存时系统内存不足异常?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆