Is this a local variable?
If so, you are trying to allocate 25,600,000 bytes on the stack.
(100000 * 32 * 8)
That is highly unlikely to work on any machine! The default on Windows machines is 1MB per thread (I think).
You will have to allocate from the heap, either with a 'new' or use a std::vector.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Is this a local variable?
If so, you are trying to allocate 25,600,000 bytes on the stack.
(100000 * 32 * 8)
That is highly unlikely to work on any machine! The default on Windows machines is 1MB per thread (I think).
You will have to allocate from the heap, either with a 'new' or use a std::vector.
Hello JohnW,
These are the local variables. Could you please give me an example? How to use heap?
My array is exactly A[100000][3]. So, it comes (100000 * 3 * 8)/(1024*1024) = 2.28MB.
#include <vector>
using namespace std;
int main()
{
const int i = 100000;
const int j = 32;
vector<vector<__int64>> A(i, vector<__int64>(j));
}
Though if you are going to have large 2D arrays then it is often better to wrap a 1D vector in a class and let the interface emulate the 2D aspect. In that way there is only one allocation of memory and a lot less heap fragmentation.
You can write your own fairly simply or Use Boost's multi_array.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Bookmarks