title: Android: Increase call stack size
body: <p>I have an application with very complex UI, containing many <code>layouts</code> nested one in another. While Creating another layout, I've caught a <code>StackOverflowError</code></p>
  
  <p>Wondering, I've created two test examples:</p>
  
  <p>1) Hello world application with following <code>xml</code> for main Activity</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;FrameLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" &gt;
  
          &lt;FrameLayout
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" &gt;
  
              &lt;!-- ...So on 30 times... --&gt;
  
                  &lt;FrameLayout
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent" &gt;
  
                  &lt;/FrameLayout&gt;
  
              &lt;!-- ...So on 30 times... --&gt;
  
          &lt;/FrameLayout&gt;
      &lt;/FrameLayout&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>causes StackOverflowError while drawing the layout (cause every layout recursively draws it's children)</p>
  
  <p>2) The following test case</p>
  
  <pre><code>public class TestOverflowActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          overflow(0);
      }
  
      private void overflow(int i){
          android.util.Log.i("Stack depth:", " = " + i);
          overflow(i+1);
      }
  }
  </code></pre>
  
  <p>causes <code>StackOverflowError</code> on depth about 260-270 calls. </p>
  
  <p>Every call of stack element for second test case takes 4 bytes for return address <code>+ 4 bytes</code> for parameter <code>= 8 bytes</code>. It's possible that <code>Dalvik's</code> VM keeps a bit more info in every element, but even <code>16 bytes per element * 260 calls = about 4Kbytes</code> for maximum overall stack size. This does not seem enough.</p>
  
  <p>Is there any way to increase maximum stack size?</p>