How do i increase the size of the program stack?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lianne.ribeiro@gmail.com

    How do i increase the size of the program stack?

    I am using Visual C++ 6 IDE,with 512MB RAM. I have coded a recursive
    function that has a correct end condition for recursion. There is no
    infinite recursion.

    For some input data,the recursive function gets called so many times
    that it causes a 'First-chance exception in a.exe: 0xC00000FD: Stack
    Overflow.'

    How do i increase the size of the program stack?
  • Richard Tobin

    #2
    Re: How do i increase the size of the program stack?

    In article <6ca1d34d-c738-43b2-9016-d80e917ac3f1@d2 1g2000prf.googl egroups.com>,
    <lianne.ribeiro @gmail.comwrote :
    >I am using Visual C++ 6 IDE [...]
    >How do i increase the size of the program stack?
    If you don't get an answer here, try a Microsoft newsgroup. Controlling
    the stack size varies between operating systems.

    -- Richard



    --
    :wq

    Comment

    • Malcolm McLean

      #3
      Re: How do i increase the size of the program stack?


      <lianne.ribeiro @gmail.comwrote in message
      >I am using Visual C++ 6 IDE,with 512MB RAM. I have coded a recursive
      function that has a correct end condition for recursion. There is no
      infinite recursion.
      >
      For some input data,the recursive function gets called so many times
      that it causes a 'First-chance exception in a.exe: 0xC00000FD: Stack
      Overflow.'
      >
      How do i increase the size of the program stack?
      >
      As Richard Heathfield has pointed out, there is a way.
      However a better solution is to cut down on the amount of recursion.
      Take all constant parameters out of your call and put them in globals. Then
      get rid of any unnecessary local variables.
      If that doesn't work reduce everything to one pointer which you allocate and
      deallocate with malloc().
      If you need more than about nested 250,000 calls then seriously look at your
      data structure and or algorithm. That looks to me like a linked list rather
      than a tree.

      --
      Free games and programming goodies.


      Comment

      • =?UTF-8?B?Sm/Do28gSmVyw7NuaW1v?=

        #4
        Re: How do i increase the size of the program stack?

        Malcolm McLean wrote:
        Take all constant parameters out of your call and put them in globals.
        Or declare them as static.

        JJ

        Comment

        • =?UTF-8?B?Sm/Do28gSmVyw7NuaW1v?=

          #5
          Re: How do i increase the size of the program stack?

          Richard Heathfield wrote:
          As regular readers of this newsgroup are well aware, C programs don't have
          a stack. Nevertheless, the size of this non-existent stack is indeed
          configurable in Visual C++ 6.
          It's so commonplace to have C call-chains implemented with the processor
          stack that people often forget this point (me, for example!)...

          JJ

          Comment

          Working...