Path: utzoo!attcan!uunet!ns-mx!iowasp.physics.uiowa.edu!maverick.ksu.ksu.edu!zaphod.mps.ohio-state.edu!rpi!image.soe.clarkson.edu!mic From: mic@sun.soe.clarkson.edu (Mic Lacey) Newsgroups: comp.lang.c Subject: RE: Turbo C stack size Message-ID: <1990Jul20.115711.631@iowasp.physics.uiowa.edu> Date: 20 Jul 90 16:57:11 GMT Lines: 44 Message-ID: <1990Jul20.154753.23714@sun.soe.clarkson.edu> Organization: Clarkson University, Potsdam, NY Date: 20 Jul 90 15:47:53 GMT Lines: 41 PQ Andy, I have had the same problem with running out of stack space using Turbo C 2.0. I am pretty sure (but by no means positive) that you are limited to 64k worth of stack space. This becomes a problem when you call functions that allocated large local variables (as these variables are allocated on the stack when the function is called)d It can also be a problem if you call may functions from within functions (this is a common problem with recusive functions). I suspect you are running out of space because your functions allocate too many variables on the stack. A possibile solution to this problem is to malloc those large variables when the function begins (and make sure to free them before leaving the function). When you malloc a variable the space is allocated off the heap, which is the space above the stack and below the top of memory. Try something like this: int foo(int c) { char *array; array = (char *) malloc(SOME HUGE NUMBER); ... } instead of: int foo(int c) { char array[SOME HUGE NUMBER]; ... } Good luck!!