.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 ...
随机推荐
- 【工具】用命令行与Python使用YARA规则
1.前言 YARA是一款旨在帮助恶意软件研究人员识别和分类恶意软件样本的开源工具,使用YARA可以基于文本或二进制模式创建恶意软件家族描述与匹配信息.现在已经被多家公司所运用于自身的产品. 2.YAR ...
- linux批量关闭进程
ps aux | grep gunicorn_api | awk '{print $2}' | xargs kill -9 gunicorn 换成你的关键字即可.
- 初始ADO.NET数据操作
以下介绍直接来源与百度百科,介绍十分全面和详细,作为小菜的我们没有理由不看完这些枯燥的介绍原有: ADO.NET的名称起源于ADO(ActiveX Data Objects),是一个COM组件库,用于 ...
- 关于sklearn,监督学习几种模型的对比
# K近邻,适用于小型数据集,是很好的基准模型,容易解释 from sklearn.neighbors import KNeighborsClassifier # 线性模型,非常可靠的首选算法,适用于 ...
- python3操作sqlserver,查询数据统计导出csv
import pymssql #导入sqlserver连接池模块 import csv #导出csv文件使用模块 conn=pymssql.connect('服务器ip','用户名','密码','数据 ...
- emulator: ERROR: x86 emulation currently requires hardware acceleration!Please ensure Intel HAXM is properly installed and usable.CPU acceleration status: HAX kernel module is not installed!
Android Studio 1.0 已经放出来了,以后的Android平台开发激昂逐步从Eclipse向Android Studio迁移,为了能不落伍我也特意从Google下载了Android St ...
- SSD安装记录
这两天配置SSD,折腾了一两天,终于搞定了,记录下自己遇到的大坑. 1.安装SSD 安装参考:http://blog.csdn.net/shawncheer/article/details/53227 ...
- tomcat错误信息解决方案【严重:StandardServer.await: create[8005]】
错误信息: 严重: StandardServer.await: create[8005]: java.net.BindException: Address already in use: JVM ...
- 重装Ubuntu时如何保留/home分区中的数据
重装Ubuntu时如何保留/home分区中的数据作者:maowang Windows系统可以在重装时只格式化C盘,从而保留其他分区的数据. Ubuntu系统也可以,只要在安装系统时分出一个/home分 ...
- JS实现集合和ECMA6集合
集合类似于数组,但是集合中的元素是唯一的,没有重复值的.就像你学高中数学的概念一样,集合还可以做很多比如,并集,交集,差集的计算.在ECMA6之前,JavaScript没有提供原生的Set类,所以只能 ...