Very large array on the heap (Visual C++)

后端 未结 6 794
一向
一向 2021-01-22 21:00

I hope some one can help me, i\'m trying to create an int[400000000] (400 millions) array on my application using visual c++ 2010 but it generates an overflow error The same cod

6条回答
  •  长情又很酷
    2021-01-22 22:03

    If you are using a 32-bit application then by default you have just 2GB of user address space. 400 million integers is about 1.5GB. You are very likely not to have this much contiguous address space. It is possible to force 32-bit windows to allocate a 3GB user address space for each process but this may just be a stop gap for your situation.

    If you can move to a 64-bit architecture then this should not be an issue; otherwise you should find a way of storing your matrix data in a way that does not require a single block of contiguous storage, for example storing it in chunks.

提交回复
热议问题