title: How to increase stack size for a ruby app. Recursive app getting: Stack level too deep (SystemStackError)
body: <p>Posting a stack overflow question on stackoverflow.com, how amusing :-)</p>
  
  <p>I'm running some recursive Ruby code and I get the: <code>"Stack level too deep (SystemStackError)"</code></p>
  
  <p>(I'm quite sure the code works, that I'm not in an infinite recursive death spiral, but that is not the point anyway)</p>
  
  <p>Is there anyway to change the allowed stack depth/size for my Ruby app?</p>
  
  <p>I don't quite get it if this is a restriction in Ruby, since the error says "Stack level", which gives me the impression that Ruby somehow counts 'levels' of stack, or if it simply means that the stack is full.</p>
  
  <p>I have tried running this program under both Vista and Ubuntu with same result.
  Under Ubuntu i tried changing the stack size with 'ulimit -s' from 8192 to 16000, but that didn't change anything.</p>
  
  <p>Edit:
  Thanks for the feedback.<br>
  I do realize that using a recursive function perhaps isn't the most robust way to go.
  But that isn't the point either. 
  I simply wonder if there is a way to increase the stack size.. period.
  And as I mentioned i did try running ulimit -s 16000 before running the ruby script.. with no improvement.. Am I using it wrong?</p>
  
  <p>Edit2:
  I was in fact having an infinite recursion in an edge case of the code. <br>The truncated ruby stack trace when you get the <code>"Stack level too deep"</code> error is a bit misleading. <br>When having a recursive behavior involving several functions, you get the impression that the numbers of recursions is much lower than it actually is. In this example one might thing that it crashes after little bit more than 190 calls, but it is actually around 15000 calls</p>
  
  <pre><code>tst.rb:8:in `p': stack level too deep (SystemStackError)
          from tst.rb:8:in `bar'
          from tst.rb:12:in `bar'
          from tst.rb:19:in `foo'
          from tst.rb:10:in `bar'
          from tst.rb:19:in `foo'
          from tst.rb:10:in `bar'
          from tst.rb:19:in `foo'
          from tst.rb:10:in `bar'
           ... 190 levels...
          from tst.rb:19:in `foo'
          from tst.rb:10:in `bar'
          from tst.rb:19:in `foo'
          from tst.rb:22
  </code></pre>
  
  <p>-Andreas</p>