Java: Would decreasing the stack size speed up frequent method invocations?
Everywhere I keep reading about increasing the JVM stack size (i.e. to allow deeper recurs开发者_StackOverflow中文版ions).
But I'm asking myself, would decreasing of the stack size speed up method invocation?
Probably my understanding is wrong, but I assume, that the allocation speed of each stack (not only for recursive method calls) depends on it's size.
Could someone point me to benchmarks, or at least to background information on this topic?
Thank you!
Each platform's virtual machine implementation of Java will be different, but in general, this is not going to be a factor that has a significant impact. Allocating memory is an extremely common operation and is likely to be highly optimized.
For example, it would be easy to have an implementation which uses a list of (pointer, size)
tuples to indicate stack space. Now you only have to say the size
of the stack you would like and the pointer
that points to the beginning of the reserved space, no matter how much space you want.
精彩评论