问题描述
我正在使用共享类(如下面所示)或作为实体POCO对象将某些表缓存到内存中.我都尝试过.
公共共享函数CacheDT()作为cacheDS.CacheDataTable 如果_CacheDT什么都没有,则 将myCacheTableAdapter调暗为新的cacheDSTableAdapters.CacheTableAdapter _CacheDT = myCacheTableAdapter.GetData() 万一 返回_CacheDT 结束功能
在我的数据库中有很多不经常更改的表.这就是为什么我要在内存中缓存大约2 GB的数据.我的开发人员计算机的RAM为16 GB,Web服务器的RAM为64 GB.我正在系统内存不足异常正常 内存使用量甚至达不到8 GB.我发现有一篇很好的文章向我解释了这与物理内存无关,只是解决了事实
在文章中,他说这对64位计算机应该不是问题,但是我的两台计算机都是64位.它是怎么发生的?如何通过在VB或C#中设置内容或对代码进行编码来管理内存?
当我禁用名为启用Visual Studio托管过程"的选项时,它开始更频繁地发生.可能与此有关吗?
感谢您的建议.
"调试的难度是一开始编写代码的两倍.因此,如果您尽可能聪明地编写代码,那么根据定义,您就不够聪明,无法对其进行调试."
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."
这篇关于有50%的可用内存时系统内存不足异常?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!