java.is.for.desktop
java.is.for.desktop

Reputation: 11216

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 recursions).

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!

Upvotes: 0

Views: 257

Answers (1)

John Feminella
John Feminella

Reputation: 311536

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.

Upvotes: 1

Related Questions