Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase agent stack size #2

Open
dehubbed opened this issue Jun 30, 2012 · 0 comments
Open

increase agent stack size #2

dehubbed opened this issue Jun 30, 2012 · 0 comments

Comments

@dehubbed
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant