You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per default newly created threads have a stack size of 8kb on Android/Dalvik which is a lot less than the usual 256-512 kB on a 'normal' JVM. This limit is easily hit when e.g. "eval"-ing moderately complex expressions.
In places where one is in control of creating new threads in one's own project one can easily use the Thread constructor that allows one to specify a stack size. However Clojure creates threads implicitly, e.g. for agents.
Changing createThreadFactory in clojure.lang.Agent fixes this:
private static ThreadFactory createThreadFactory(final String format, final AtomicLong threadPoolCounter) {
return new ThreadFactory() {
public Thread newThread(Runnable runnable) {
return new Thread(Thread.currentThread().getThreadGroup(),
runnable, String.format(format, threadPoolCounter.getAndIncrement()), 256 * 1204);
}
};
}
This could be amended to only explicitly set the stack size explicitly if the DalvikVM has been detected and leave it to the default otherwise.
The text was updated successfully, but these errors were encountered:
Per default newly created threads have a stack size of 8kb on Android/Dalvik which is a lot less than the usual 256-512 kB on a 'normal' JVM. This limit is easily hit when e.g. "eval"-ing moderately complex expressions.
In places where one is in control of creating new threads in one's own project one can easily use the Thread constructor that allows one to specify a stack size. However Clojure creates threads implicitly, e.g. for agents.
Changing createThreadFactory in clojure.lang.Agent fixes this:
private static ThreadFactory createThreadFactory(final String format, final AtomicLong threadPoolCounter) {
return new ThreadFactory() {
public Thread newThread(Runnable runnable) {
return new Thread(Thread.currentThread().getThreadGroup(),
runnable, String.format(format, threadPoolCounter.getAndIncrement()), 256 * 1204);
}
};
}
This could be amended to only explicitly set the stack size explicitly if the DalvikVM has been detected and leave it to the default otherwise.
The text was updated successfully, but these errors were encountered: