首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#需怎样才能使用更多内存

2013-07-16 
C#需要怎样才能使用更多内存?如下程序,运行时内存不足,请问该怎么做才能使得程序运行正确:64位机器,实际内

C#需要怎样才能使用更多内存?
如下程序,运行时内存不足,请问该怎么做才能使得程序运行正确:
64位机器,实际内存很丰富,是不是需要在App.config里怎么配置一下?谢谢了!
快速结贴!!!
    class Program
    {
        static void Main(string[] args)
        {
            byte[] b1 = new byte[1024 * 1024 * 1024];
            byte[] b2 = new byte[1024 * 1024 * 1024];
            byte[] b3 = new byte[1024 * 1024 * 1024];
            byte[] b4 = new byte[1024 * 1024 * 1024];
            byte[] b5 = new byte[1024 * 1024 * 1024];
            byte[] b6 = new byte[1024 * 1024 * 1024];
            byte[] b7 = new byte[1024 * 1024 * 1024];
            byte[] b8 = new byte[1024 * 1024 * 1024];
            byte[] b9 = new byte[1024 * 1024 * 1024];
            byte[] b10 = new byte[1024 * 1024 * 1024];
         }
    } C# 内存
[解决办法]
这代码用到10GB内存了。如果你要使用2GB以上的数组,试试看BigArray<T>

http://blogs.msdn.com/b/joshwil/archive/2005/08/10/450202.aspx
[解决办法]

引用:
楼上给的链接,第一段就是:
I’ve received a number of queries as to why the 64-bit version of the 2.0 .Net runtime still has array maximum sizes limited to 2GB. Given that it seems to be a hot topic of late I figured a little background and a discussion of the options to get around this limitation was in order.



大概就是说:.net只给一个进程最多2G内存?这样的话用不用BigArray<T>意义不大。


why the 64-bit version of the 2.0 .Net runtime still has array maximum sizes limited to 2GB
是数组大小,不是进程内存大小。
[解决办法]
要用到这么大的内存的程序一定不正常,是否程序的设计思路有问题?
[解决办法]
C#需怎样才能使用更多内存
http://www.cnblogs.com/eaglet/archive/2008/11/06/1328061.html
[解决办法]
用完释放掉就行阿。程序一般要避免使用内存过多。
[解决办法]
分开几个程序,分布式计算不好么?

热点排行