Click here to Skip to main content
15,902,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Am creating a static array of size data_node arr[131072]. But while compiling am getting the error as "array size is too large " (gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)) .

And the size of data_node is around 972 byte. While going through some discussion I saw they are suggesting about increasing the stack size. For now I have set it to unlimited.


stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited

Any suggestion.
Posted

1 solution

If it's a static array, stack size is not being concerned as it will be allocated as part of the data section of your program and not on the stack. If you however mentioned "static" just accidentally or meaning "not by alloc (..)" then this explanation might be right. In that case I would recommend to use the head anyway. So allocate it by
C++
data_node* pNodes;
...
pNodes = alloc (sizeof (data_node) * 131072);
...
free (pNodes);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900