且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有50%的可用内存时系统内存不足异常?!

更新时间:2023-01-14 14:08:28

您是否为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