Dalvik had separate stacks for native and Java code, with a default Java stack size of 32KB and a default native stack size of 1MB.
java栈32KB,Native栈 1MB
如果线程的栈空间不足,报了StackOverflowError
错误。可以将设置更大的栈空间。
设置方式,注意Native 设置方法是在ART模式下:
- In Java, review calls to the
Thread
constructor that specify an explicit stack size. For example, you will need to increase the size ifStackOverflowError
occurs. - In C/C++, review use of
pthread_attr_setstack()
andpthread_attr_setstacksize()
for threads that also run Java code via JNI. Here is an example of the error logged when an app attempts to call JNIAttachCurrentThread()
when the pthread size is too small:F/art: art/runtime/thread.cc:435] Attempt to attach a thread with a too-small stack (16384 bytes)