.NET Out Of Memory Exception - Used 1.3GB but have 16GB installed
I am getting an Out Of Memory exception in my c# application when the memory usage for the application goes over about 1.3GB.
I had this same problem on a 32-bit machine with 3gb of memory and it made sense back then, but now I upgraded the hardware to a 64-bit machine with 16GB memory with the high - end motherboard and RAM but the Out Of Memory exception still occurs after 1.3GB!
I know that there are no single objects over 2GB and 1.3 is less the 2GB anyway, so the in-built MS 2GB limit on a single object is not likely to be the problem...
It seems like there is a windows kill-switch of some sort when an app reaches a certain memory usage threshold... Then there should be a way to configure this is in the registry perhaps?
Any help will be greatly appreciated!
Solution1:
There is no difference until you compile to same target architecture. I suppose you are compiling for 32 bit architecture in both cases.
It's worth mentioning that OutOfMemoryException can also be raised if you get 2GB of memory allocated by a single collection in CLR (say List<T>) on both architectures 32 and 64 bit.
To be able to benefit from memory goodness on 64 bit architecture, you have to compile your code targeting 64 bit architecture. After that, naturally, your binary will run only on 64 bit, but will benefit from possibility having more space available in RAM.
Solution2:
As already mentioned, compiling the app in x64 gives you far more available memory.
But in the case one must build an app in x86, there is a way to raise the memory limit from 1,2GB to 4GB (which is the actual limit for 32 bit processes):
In the VC/bin folder of the Visual Studio installation directory, there must be an editbin.exe file. So in my default installation I find it under
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\editbin.exe
In order to make the program work, maybe you must execute vcvars32.bat in the same directory first. Then a
editbin /LARGEADDRESSAWARE <your compiled exe file>
is enough to let your program use 4GB RAM. <your compiled exe file> is the exe, which VS generated while compiling your project.
If you want to automate this behavior every time you compile your project, use the following Post-Build event for the executed project:
if exist "$(DevEnvDir)..\tools\vsvars32.bat" (
call "$(DevEnvDir)..\tools\vsvars32.bat"
editbin /largeaddressaware "$(TargetPath)"
)
Sidenote: The same can be done with the devenv.exe to let Visual Studio also use 4GB RAM instead of 1.2GB (but first backup the old devenv.exe).
.NET Out Of Memory Exception - Used 1.3GB but have 16GB installed的更多相关文章
- Why does Delphi XE7 IDE hangs and fails on out of memory exception?
引自: https://stackoverflow.com/questions/27701294/why-does-delphi-xe7-ide-hangs-and-fails-on-out-of ...
- 记32位程序(使用3gb用户虚拟内存)使用D3DX9导致的一个崩溃的问题
为了增加32位程序的用户虚拟内存的使用量,我们使用了/LARGEADDRESSAWARE编译选项来使32位程序可能使用到3gb的内存,能否使用到3gb内存也跟平台.系统和设置有关系,现摘抄部分作为参考 ...
- Memory Limits for Windows and Windows Server Releases
来源:https://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx Limits on memory ...
- [转帖]Docker容器CPU、memory资源限制
Docker容器CPU.memory资源限制 https://www.cnblogs.com/zhuochong/p/9728383.html 处理事项内容等 这一块内容感觉 不清楚.. 背景 在使用 ...
- 查看 Linux memory 内存占用
linux 系统内存: 如果系统内存使用过高 就会产生 out of memory exception 现象: 通常 在mongo 默认服务运行资源是不受限制的.也会占用而同一系统运行的其他服务: 当 ...
- Docker(二十)-Docker容器CPU、memory资源限制
背景 在使用 docker 运行容器时,默认的情况下,docker没有对容器进行硬件资源的限制,当一台主机上运行几百个容器,这些容器虽然互相隔离,但是底层却使用着相同的 CPU.内存和磁盘资源.如果不 ...
- [转载]Memory Limits for Windows and Windows Server Releases
Memory Limits for Windows and Windows Server Releases This topic describes the memory limits for sup ...
- Docker容器CPU、memory资源限制
背景 在使用 docker 运行容器时,默认的情况下,docker没有对容器进行硬件资源的限制,当一台主机上运行几百个容器,这些容器虽然互相隔离,但是底层却使用着相同的 CPU.内存和磁盘资源.如果不 ...
- ui自动化测试数据复原遇到的坑——2、python连接informix时pytest报致命错误Windows fatal exception: access violation
python连接informix只能通过jdbc(需要先部署java环境.我试过到IBM上下载ODBC但结局是失败的),在执行pytest时发现有一串报错(大致是下面的这样): Windows fat ...
随机推荐
- Redis持久化——RDB快照
一.是什么? 在指定的时间间隔内将内存中的数据集快照写入磁盘,也就是行话讲的Snapshot快照,它恢复时是将快照文件直接读到内存里. Redis会单独创建(fork)一个子进程来进行持久化,会先将数 ...
- 转:VMWare服务器虚拟化--转自CSDN
http://blog.csdn.net/kkfloat/article/category/1249845/3
- Laravel Model 的 fillable (白名单)与 guarded (黑名单)
例如 protected $fillable = ['name']; protected $guarded = ['price']; 定义了 name 字段可以写入/修改,而 price 字段不可以. ...
- Excel学习笔记:sumif、sumifs、countifs函数使用方法
本篇纯粹记录一下sumif.sumifs.countifs函数的使用方法. 一.sumif函数 按条件求和 使用格式:=sumif(条件区域,求和条件,实际求和区域) =SUMIF($B$7:$B$1 ...
- Vue 动态组件渲染问题分析
fire 读在最前面: 1.本文适用于有一定基础的vue开发者,需要了解基本的vue渲染流程 2.本文知识点涉及vue构造器以及选项策略合并.<component> 渲染逻辑 问题描述: ...
- KnockoutJs学习笔记(六)
这篇文章主要涉及control flow部分的binding. foreach binding主要作用于lists或是tables内数据单元的动态绑定.下面是一个简单的例子: js部分: ko.app ...
- 【LOJ】#2551. 「JSOI2018」列队
题解 老年选手一道裸的主席树都要看好久才看出来 首先熟练的把这个区间建成\(n\)个主席树 然后对于一个询问,我们相当于在主席树上二分一个mid,使得\(mid - K + 1\)正好和\([l,r] ...
- linux下常用的日志分析命令
linux下常用的日志分析命令 本文介绍下,在linux中常用的一些分析日志的命令行或脚本,有需要的朋友参考下. 形如下面这样的access.log日志内容: 211.123.23.133 ...
- grep 详解
grep 是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来.(global search regular expression(RE) and print out the l ...
- 【BZOJ 1430】 1430: 小猴打架 (Prufer数列)
1430: 小猴打架 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 625 Solved: 452 Description 一开始森林里面有N只互不相 ...