How to increase stack size in Bloodshed Dev-C++?

Go To StackoverFlow.com

0

We are using Blodshed Dev-C++ to in an image processing project. We are implementing connected component labelling on a video frame. We have to use a recursive function which recurses so many times that we get a stackoverflow. How can we have a larger stack size? Is it possible to change it through some linker parameters or anything similar?

void componentLabel(int i,int j,IplImage *img){
  //   blueFrame = img->imageData[i*3*width+j*3];
//     greenFrame = img->imageData[i*3*width+j*3+1];
//     redFrame = img->imageData[i*3*width+j*3+2];

     if(!( img->imageData[i*3*width+j*3]==0 && img->imageData[i*3*width+j*3+1]==0 && img->imageData[i*3*width+j*3+2]==0 )  ){
           //printf("iffffff aq\n");
           return;     
     }
     else{
           //printf("else aq  %d\n",sayac_label);                          
               img->imageData[i*3*width+j*3]=1;  

               new_object.pixel_count=new_object.pixel_count+1;
               new_object.total_row=new_object.total_row+i;
               new_object.total_col=new_object.total_col+j;

               if(j<width-1 ){                   
                         componentLabel(i,j+1,img);                         
               }               
               if(j>0 ){                   
                         componentLabel(i,j-1,img);                   
               }             
               if(i<height-1 ){  
                         if(i>new_object.bottom.satir){
                              new_object.bottom.satir=i;
                              new_object.bottom.sutun=j;                                               
                         }

                         componentLabel(i+1,j,img);                         
               }              
               if(i>0 ){ 
                         if(i<new_object.top.satir){
                              new_object.top.satir=i;
                              new_object.top.sutun=j;                                               
                         }                  
                         return componentLabel(i-1,j,img);               
               }      
     }
2012-04-04 19:47
by Yilmaz Paçariz
Please tell me you're using the recent version of DevC++ and not the 5+ year old one - Mysticial 2012-04-04 19:48
dev-c++ 4.9.9. - Yilmaz Paçariz 2012-04-04 19:49
facepalm...... - Mysticial 2012-04-04 19:51
Ooh, seven years - Mr Lister 2012-04-04 19:52
is there any solution - Yilmaz Paçariz 2012-04-04 19:54
blödschaden devcpp how appropriat - sehe 2012-04-04 19:55
Perhaps you should consider a different alogorith - Collin 2012-04-04 19:56
If you can show us your algo, people can suggest alternate method - Pavan Manjunath 2012-04-04 19:58
Dev C++ is using a very old version of gcc ( 3.4.2 ) which does not support the --stack linker option. Shift to linux, you can infact set stack limit programatically using setrimit() : - Pavan Manjunath 2012-04-04 20:33
what about using later version of DEV C++ - Yilmaz Paçariz 2012-04-04 20:49
@sehe Blutvergießen, actually - Mr Lister 2012-04-05 07:47
@MrLister I know, I wasn't translating? I was punning (badly) since the consequent spelling blodsheet reminded me of red nicht so blöd!sehe 2012-04-05 08:19


1

Only one approach will guarantee that you won't run out of stack size - reformulate the algorithm to be tail recursive (and ensure that your compiler is optimizing tail calls - usually an -O3 (or -O2?) optimization flag).

Short of that, have you increased the maximum stack size that the shell will grant your task?

  ulimit -s <maximum stack size>
2012-04-15 04:29
by GoZoner
Ads