ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
im stuck again with something simple. there is a 4-dimensional array, but it gives segmentation fault when one of dimensions is big like 30000. dont know why :"(
int main (int argc, char* argv[])
{
printf("!!!!1 \n");
int m[18][30][N_I][4];
int i,j,k,l;
for (i=0;i<18;i++)
for (j=0;j<30;j++)
for (k=0;k<N_I;k++)
for (l=0;l<4;l++)
{
m[i][j][k][l]=i+j+k+l;
printf("%d\n",m[i][j][k][l]);
}
return 0;
}
it works fine when N_I=300; but crashes when N_I=30000;
ups, i think i got it, i run in on cluster and since big arrays take a lot of space may be it was not allowed to take it, but when i run it on my laptop it works.
You cant use that many loops. Your program crashes. Depending on how much your RAM capacity is, there are limitations.
Once I was trying to create a word combination list, I used multiple for loops but my core got dumped.
Its way more complex than you could understand.
Last edited by Nathan.eth0; 05-31-2011 at 12:30 PM.
ups, i think i got it, i run in on cluster and since big arrays take a lot of space may be it was not allowed to take it, but when i run it on my laptop it works.
sorry
If you wish, try increasing the size of your stack, using the following command:
Code:
ulimit -s unlimited
Then re-run your program.... but seriously, why would you want to? Do you really want the program looping so many times?
Next time, if you require a large array (single or multi-dimensional), allocate it on the heap rather than declare it on the stack.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.