Reputation: 69
I am trying to create a very large array, to which, I then get the following error.
char largearray[1744830451];
warning LNK4084: total image size 1750372352 exceeds max (268435456); image may not run
I was told I could use a C-array and not C++ . I'm not sure I fully understood my friend's response. I am currently using Visual Studio 6.0 C++ . Do I need to get another compiler to do straight C or is it a method to how to declare the array that needs to change?
If I need to change compilers, does someone have suggestions?
Upvotes: 0
Views: 1109
Reputation: 336
If you predefine the size, then you are restricted to the stack size (stack has less size but faster), so it is better to define the size dynamically, which means your data is stored in heap (heap has bigger size but a little bit slower than stack).
Have a look at http://gribblelab.org/CBootcamp/7_Memory_Stack_vs_Heap.html which explains the difference of stack and heap.
Upvotes: 0
Reputation: 155250
The char array[size]
syntax means the array will be created in the data section of your compiled program and not allocated at runtime.
Win32 PE code cannot exceed 256MB (according to your linker's error message), but the array you're declaring is 1.6GB in length.
If you want a 1.6GB array, use malloc
(and don't forget to call free
!)
...but why on earth are you running VC6?
Upvotes: 4