Out of memory exception on 64bit

↘锁芯ラ 提交于 2019-12-10 16:33:30

问题


im trying to create the following array

int numOfArrays = 50000;
int lengthOfArrays = 13500;

long[,] unsortedNumbers = new long[numOfArrays,lengthOfArrays];

but i keep getting the out an memory exception. Im targeting x64, i believe ive set the large-address-aware flag, see pic, yet im still getting the error. Odd thing is, i have a list in the same program which consumes 16gig of ram without any issues.

System:

64gig ram

100gig free on hd.


回答1:


There's a 2Gig Limit in the .NET Framework in 4 and below...but in 4.5 you can increase the limit with gcAllowVeryLargeObjects.

  • Memory limitations in a 64-bit .Net application?

You are allocating:

50000 * 13500 * 8 = 5400000000 bytes = 5.029 gigabytes

If you don't have the luxury of using NET 4.5 then depending on your usage scenario you may be able to use BigArray instead:

  • http://blogs.msdn.com/b/joshwil/archive/2005/08/10/450202.aspx


来源:https://stackoverflow.com/questions/17808946/out-of-memory-exception-on-64bit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!