日期:2014-05-17  浏览次数:20702 次

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.