如题,但是却报错内存不可度,估计是没有可用虚拟内存。windows中每个程序不是有4G虚拟内存吗,为什么我才开了1G它就报错了?这个问题的可能解决办法如何?

解决方案 »

  1.   

    栈的大小可以在建立工程时指定。
    堆的大小当然受系统实际内存限制。
    如果真要开辟非常非常大的数组,就用VirtulAlloc,
    理论上可以达到4G
      

  2.   

    VirtulAlloc和new开辟内存有什么区别呢?
      

  3.   

    VirtualAlloc并不能比new更有效的工作,系统分配内存最终只有一个方法,所有的函数分配内存最终都要调用系统分配内存的方法。
    理论上的内存值,和你机器硬件上的内存大小,还是有区别的。比如你机器有256内存,和512的虚拟内存,现有系统用去了200M内存,那你可以开辟的最大内存就是(512+256-200)M。考虑到内存的不连续性,实际上在这个系统中你可以new的内存块,一次也许不能超过200M。
      

  4.   

    不用那么大吧,想确认的话发个mail给microsoft吧
      

  5.   

    The 4G address space is divided into 2G user mode address space and 2G kernel mode address space. So application can only control the 2G user mode address space.Within the 2G space, lots of system DLLs are loaded at fixed location. For example kernel32.dll, gdi32.dll, user32.dll, your EXE and your DLLs. After this, the usable free address space is around 1.4 GB.There is a version of Windows OS which allows 3G user mode address space and 1G kernel mode address space. But system DLLs are still loaded at the same addresses. With this option, it may be possible to allocate more than 2G of space, but may be not in a single chunk.Your options:1) Optimize your data structure to reduce data requirement.
    2) Use the 3G option, possible rebase DLLs.
    3) Use another process.
    4) Use files on disk to load data into memory when it's needed.
    5) Move to 64-bit machine.