javaandroidtimertaskstack-size

How can I change the stack size (of a thread) in my Android Application?


I'm getting a stackoverflow error in my service which is attached my to my main activity. Is there a way to change the stack size within my service ? I came across the Xss parameter, however, apparently its not available in the vm options (Help->Edit vmoptions).

A bit of the background: I'm getting the error when I try to read a serialized machine learning model in code and then de-serialize it. The same function works fine when this model is built on a small dataset, but doesn't work when I built the same model with a bigger daatset.

Any ideas on how can I do it ?


Solution

  • You can't change the stack size of your app, however you can create a new thread and set the stack size for new thread using this constructor:

    constructor Thread (ThreadGroup group, Runnable target, String name, long stackSize)

    Anyway a new thread is a good idea as you get a clean stack. The Android main thread has already about 10 entries that belong to Dalvik and other parts of the system...