.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 ...
随机推荐
- Dhaka2011
Dhaka2011 A - Binary Matrix 题目描述:有一个\(n \times m\)的\(01\)矩阵,这一矩阵第一行和最后一行是相邻的,第一列和最后一列是相邻的,现在每次可以交换相邻 ...
- Java IO流杂谈
创建文件和删除文件(File类) import java.io.File; import java.io.IOException; public class T2 { public static vo ...
- apollo配置相关
一.运维 1. 数据库ConfigDB,PortalDB 2. 基础服务 :Config-Service,(Meta-Server),Admin-Service,Portal 3. 应用在SIT.UA ...
- 字符串前面加u、r、b的含义
u/U:表示unicode字符串 不是仅仅是针对中文, 可以针对任何的字符串,代表是对字符串进行unicode编码. 一般英文字符在使用各种编码下, 基本都可以正常解析, 所以一般不带u:但是中文, ...
- Python 爬虫入门之爬取妹子图
Python 爬虫入门之爬取妹子图 来源:李英杰 链接: https://segmentfault.com/a/1190000015798452 听说你写代码没动力?本文就给你动力,爬取妹子图.如果 ...
- Ueditor结合七牛云存储上传图片、附件和图片在线管理的实现和最新更新
最新下载地址: https://github.com/widuu/qiniu_ueditor_1.4.3 Ueditor七牛云存储版本 注意事项 老版本请查看 : https://github.com ...
- dojo/domReady! 中感叹号的作用
废话 其实不算个技术问题,但实在是花了我不少时间,不记下来都对不起我这浪费掉的几十分钟. 问题 在dojo官网上看教程,跟着做点练习,看到Dojo DOM Functions那节,有一个练习是改变页面 ...
- JavaScript中变量的相互引用
http://www.jb51.net/article/23387.htm
- 【LOJ】#2567. 「APIO2016」划艇
题解 显然有个很暴力的dp,\(dp[i][j]\)表示选到第\(i\)个数,末尾的数是\(j\)的方案数 但是第二维就开不下了,怎么办呢 考虑离散化整个区间,我们记录\(dp[i][j][k]\)表 ...
- 【AtCoder】ARC090
C - Candies 前一枚举一个i,求第一行的前i个和第二行从第n个到第i个 代码 #include <bits/stdc++.h> #define fi first #define ...