Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe that the main thread's stack is controlled by the JVM - in Android's case - Dalvik JVM. The relevant constant if I'm not mistaken is found in <code>dalvik/vm/Thread.h</code> under <code>#define kDefaultStackSize</code></p> <p><strong>Browsing for stack sizes through the dalvik source history:</strong></p> <ul> <li><p>API 3 (<a href="https://android.googlesource.com/platform/dalvik.git/+/4da052510571aea4711d04de25a24b58cab1dadc%5E1..4da052510571aea4711d04de25a24b58cab1dadc/">Android 1.5</a>) = <strong>8KB</strong></p></li> <li><p>API 4-10 (<a href="https://android.googlesource.com/platform/dalvik/+/android-1.6_r1/vm/Thread.h">Android 1.6</a> - <a href="https://android.googlesource.com/platform/dalvik/+/android-2.3.7_r1/vm/Thread.h">Android 2.3.7</a>) = <strong>12KB</strong></p></li> <li><p>API 14-17 (<a href="https://android.googlesource.com/platform/dalvik/+/android-cts-4.0_r1/vm/Thread.h">Android 4.0</a> - <a href="https://android.googlesource.com/platform/dalvik/+/android-4.2.2_r1.1/vm/Thread.h">Android 4.2.2</a>) = <strong>16KB</strong></p></li> </ul> <p><strong>So how many nested views can you have:</strong></p> <p>Impossible to say accurately. Assuming the stack sizes are as described above, it all depends on how many function calls you have in your deepest nesting (and how many variables each function takes, etc). It seems that the problematic area is when the views are being drawn, starting with <code>android.view.ViewRoot.draw()</code>. Each view calls the draw of its children and it goes as deep as your deepest nesting.</p> <p>I would perform empirical tests at least on the devices appearing in all the boundary groups above. It seems that using the emulator gives accurate results (although I've only compared the native x86 emulator to a real device).</p> <p>Keep in mind that optimizations to how the actual widgets / layouts are implemented may also influence this. Having said that, I believe that most of the stack space is eaten by every layout hierarchy adding about 3 nested function calls: <code>draw()</code> -> <code>dispatchDraw()</code> -> <code>drawChild()</code> and this design hasn't changed much from 2.3 - 4.2.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload