tags:

views:

617

answers:

2
+1  Q: 

Android stack size

How can i get and change the stack size (even for the main thread) of my Android application.

+1  A: 

AFAIK -Xss can be used as a command line to change the main threads stacks size, if not using the command line the app framework will use the default size. In this case if you need more stack you will need to start a thread (using this ctor) to do the work.

Nic Strong
+1  A: 

The main thread stack size is set in the firmware and cannot be modified, short of modifying the firmware for your own phone. As Mr. Strong indicates, for threads you fork, you can set your own stack size.

CommonsWare
And how can I get the stakc size of the current thread (the main thread in particular)
Arutha
I do not believe there is a way to do this at runtime. According to the Googlers, at least as of last April, the main application thread stack size was 8KB: http://groups.google.com/group/android-developers/browse_thread/thread/d880c3d5777127d9/f7465bd649f641cd
CommonsWare
It seems that it changes in 1.6 release because I've got a StackOverFlowError in 1.5 but not with 1.6. I didn't find anywhere an information about stack size increasement.
Arutha
The stack size probably remained the same, but they are using more stack space in Android. This happened with the 1.5 release as well. If the StackOverflowException shows up when Android is drawing your UI, you have too deep of a view hierarchy. Use the hierarchyviewer tool to examine the hierarchy and reduce the depth. 10 should be safe, 15 is probably going to raise the exception.
CommonsWare