General discussion

Locked

stack limit in turbo c

By dinesh.dhamija ·
Can anybody help me in increasing the stack limit in turbo C being used in recurrsion????
My program requires to have a high number of recurrsions but right now the program is exiting abruptly after doing some recurrsions(may be stack limit is reached after which program exits)

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

stack limit in turbo c

by Peter Ritchie In reply to stack limit in turbo c

There should be an option in the IDE to set the stack size. I work with MSVC, so I'm not sure where that would be in Turbo C.

In a pinch you could also add the following line to your DEF file:
STACKSIZE 10240
that sets the size of the stack to10240 bytes. You could change 10240 to be anything you want.

Collapse -

stack limit in turbo c

by dinesh.dhamija In reply to stack limit in turbo c

Poster rated this answer

Collapse -

stack limit in turbo c

by Simonas Razminas In reply to stack limit in turbo c

Stack limit? Check out $M directive. For stack we have only one segment. Very strange if you got problem with memory. If we have 64kb and function takes about 16 bytes.. so there may be 4096 times deep. Anyway.. everything you can change with options.

Collapse -

stack limit in turbo c

by dinesh.dhamija In reply to stack limit in turbo c

Poster rated this answer

Collapse -

stack limit in turbo c

by solrak29 In reply to stack limit in turbo c

Generaly, a recursive function running wild will cause a stack overflow, and in your case your claiming that your function requires so much recursion that you overflow the default stack size setup by turbo c. The default size is usually acceptable,and most compilers have an option in setting this size, but I wonder what version of turbo C you are using? I would also wonder if you considered other methods in your design of the program than using such and expensive call...sounds like you have something that is inefficient in speed and space. But pretty sure there is an option to increase the stack size in your compiler..either command line or IDE.

Collapse -

stack limit in turbo c

by dinesh.dhamija In reply to stack limit in turbo c

Poster rated this answer

Collapse -

stack limit in turbo c

by solrak29 In reply to stack limit in turbo c

ok, since I didn't get any answers like, what version of tc your using...I'll tell you this...

According to tc folks the stack size for a program is set at run time and defaults to 4k. This stack size is set by a global variable called _stklen.To change this value you just set it in your program as a global variable...not in a function, not in main...out side...like this:
--snip--
extern unsigned _stklen = 1000000000;

main()....
--snip--

Collapse -

stack limit in turbo c

by dinesh.dhamija In reply to stack limit in turbo c

Although i personally did not try it....but one of my friend did...& he says that it looks good.... Thanks for the answer....

Collapse -

stack limit in turbo c

by dinesh.dhamija In reply to stack limit in turbo c

This question was closed by the author

Back to Web Development Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums