Why does a recursive function stop on random numbers?
I wrote a small program shown below that counts how many times an infinite recursive loop will go before causing a StackOverflow error.
public class Testing {
static void p(int i) {
System.out.println("hello" + i);
i++;
p(i);
}
public static void main(String args) {
p(1);
}
}
The thing is, it errors on a different number each time, normally between 8000 and 9000. Can anyone explain why this happens?
EDIT: I'm using the Eclipse IDE, haven't tested it with other IDE's or the command line.
java recursion
add a comment |
I wrote a small program shown below that counts how many times an infinite recursive loop will go before causing a StackOverflow error.
public class Testing {
static void p(int i) {
System.out.println("hello" + i);
i++;
p(i);
}
public static void main(String args) {
p(1);
}
}
The thing is, it errors on a different number each time, normally between 8000 and 9000. Can anyone explain why this happens?
EDIT: I'm using the Eclipse IDE, haven't tested it with other IDE's or the command line.
java recursion
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
8 hours ago
It looks like the exception happens during println and the string handling, could it depend on how/when garbage collection occurs?
– Joakim Danielson
8 hours ago
add a comment |
I wrote a small program shown below that counts how many times an infinite recursive loop will go before causing a StackOverflow error.
public class Testing {
static void p(int i) {
System.out.println("hello" + i);
i++;
p(i);
}
public static void main(String args) {
p(1);
}
}
The thing is, it errors on a different number each time, normally between 8000 and 9000. Can anyone explain why this happens?
EDIT: I'm using the Eclipse IDE, haven't tested it with other IDE's or the command line.
java recursion
I wrote a small program shown below that counts how many times an infinite recursive loop will go before causing a StackOverflow error.
public class Testing {
static void p(int i) {
System.out.println("hello" + i);
i++;
p(i);
}
public static void main(String args) {
p(1);
}
}
The thing is, it errors on a different number each time, normally between 8000 and 9000. Can anyone explain why this happens?
EDIT: I'm using the Eclipse IDE, haven't tested it with other IDE's or the command line.
java recursion
java recursion
edited 8 hours ago
AfterShock360
asked 8 hours ago
AfterShock360AfterShock360
587
587
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
8 hours ago
It looks like the exception happens during println and the string handling, could it depend on how/when garbage collection occurs?
– Joakim Danielson
8 hours ago
add a comment |
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
8 hours ago
It looks like the exception happens during println and the string handling, could it depend on how/when garbage collection occurs?
– Joakim Danielson
8 hours ago
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
8 hours ago
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
8 hours ago
It looks like the exception happens during println and the string handling, could it depend on how/when garbage collection occurs?
– Joakim Danielson
8 hours ago
It looks like the exception happens during println and the string handling, could it depend on how/when garbage collection occurs?
– Joakim Danielson
8 hours ago
add a comment |
5 Answers
5
active
oldest
votes
The JVM specs very nicely explain its behavior related to stack;
Each Java Virtual Machine thread has a private Java Virtual Machine
stack, created at the same time as the thread. A Java Virtual Machine
stack stores frames (§2.6). A Java Virtual Machine stack is analogous
to the stack of a conventional language such as C: it holds local
variables and partial results, and plays a part in method invocation
and return. Because the Java Virtual Machine stack is never
manipulated directly except to push and pop frames, frames may be heap
allocated. The memory for a Java Virtual Machine stack does not need
to be contiguous.
In the First Edition of The Java® Virtual Machine Specification, the
Java Virtual Machine stack was known as the Java stack.
This specification permits Java Virtual Machine stacks either to be of
a fixed size or to dynamically expand and contract as required by the
computation. If the Java Virtual Machine stacks are of a fixed size,
the size of each Java Virtual Machine stack may be chosen
independently when that stack is created.
A Java Virtual Machine implementation may provide the programmer or
the user control over the initial size of Java Virtual Machine stacks,
as well as, in the case of dynamically expanding or contracting Java
Virtual Machine stacks, control over the maximum and minimum sizes.
The following exceptional conditions are associated with Java Virtual
Machine stacks:
If the computation in a thread requires a larger Java Virtual Machine
stack than is permitted, the Java Virtual Machine throws a
StackOverflowError.
If Java Virtual Machine stacks can be dynamically expanded, and
expansion is attempted but insufficient memory can be made available
to effect the expansion, or if insufficient memory can be made
available to create the initial Java Virtual Machine stack for a new
thread, the Java Virtual Machine throws an OutOfMemoryError.
An important point from this excerpt as far as your question is concerned:
- This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation.
Since you are not providing a stack size, JVM tries to dynamically expand the stack size as the function gets called recursively needing more stack memory. In each run, it may find different amount of dynamic memory for its stack depending on the availability of memory on your computer at that point of run. This is the reason you see a different value for the number of iterations it takes before throwing the SO error. If you configure (using Xss<size>
JVM parameter) a smaller stack size to your program, you should see mostly identical number of recursions before the SO error.
add a comment |
Might be related to how much real memory the computer can allocate to the program, while other programs and process are running in the computer
add a comment |
StackOverflowError is a error. As a error, is related to the JVM (a error is not a Exception!).
This error occurs when your stack (or method execution stack) collides with your heap size (JVM's memory).
The size of JVM's heap can be defined, but from your stack no.
add a comment |
So as others have pointed out you may have to look into what jvm is beings used and from there it might also be a good exercise to know what garbage collector (how often gc is being called ) is being used as this may give you a deeper understanding not only about stack overflow error but how generally Java works. And if really keen you could implement your own small JVM and may be with a better scheme.
add a comment |
StackOverflowError
is thrown, when stack (part of memory, where method execution stack is stored) collides with heap (memory, that allocates objects, primitives etc.). You cannot predict, when the error is thrown, because the size of stack can be dynamic unless specified by -Xss
flag. That's why there is no fixed method execution depth, that causes StackOverflowError
.
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the-Xss
command line option
– David Soroko
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.
– David Soroko
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55108159%2fwhy-does-a-recursive-function-stop-on-random-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
The JVM specs very nicely explain its behavior related to stack;
Each Java Virtual Machine thread has a private Java Virtual Machine
stack, created at the same time as the thread. A Java Virtual Machine
stack stores frames (§2.6). A Java Virtual Machine stack is analogous
to the stack of a conventional language such as C: it holds local
variables and partial results, and plays a part in method invocation
and return. Because the Java Virtual Machine stack is never
manipulated directly except to push and pop frames, frames may be heap
allocated. The memory for a Java Virtual Machine stack does not need
to be contiguous.
In the First Edition of The Java® Virtual Machine Specification, the
Java Virtual Machine stack was known as the Java stack.
This specification permits Java Virtual Machine stacks either to be of
a fixed size or to dynamically expand and contract as required by the
computation. If the Java Virtual Machine stacks are of a fixed size,
the size of each Java Virtual Machine stack may be chosen
independently when that stack is created.
A Java Virtual Machine implementation may provide the programmer or
the user control over the initial size of Java Virtual Machine stacks,
as well as, in the case of dynamically expanding or contracting Java
Virtual Machine stacks, control over the maximum and minimum sizes.
The following exceptional conditions are associated with Java Virtual
Machine stacks:
If the computation in a thread requires a larger Java Virtual Machine
stack than is permitted, the Java Virtual Machine throws a
StackOverflowError.
If Java Virtual Machine stacks can be dynamically expanded, and
expansion is attempted but insufficient memory can be made available
to effect the expansion, or if insufficient memory can be made
available to create the initial Java Virtual Machine stack for a new
thread, the Java Virtual Machine throws an OutOfMemoryError.
An important point from this excerpt as far as your question is concerned:
- This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation.
Since you are not providing a stack size, JVM tries to dynamically expand the stack size as the function gets called recursively needing more stack memory. In each run, it may find different amount of dynamic memory for its stack depending on the availability of memory on your computer at that point of run. This is the reason you see a different value for the number of iterations it takes before throwing the SO error. If you configure (using Xss<size>
JVM parameter) a smaller stack size to your program, you should see mostly identical number of recursions before the SO error.
add a comment |
The JVM specs very nicely explain its behavior related to stack;
Each Java Virtual Machine thread has a private Java Virtual Machine
stack, created at the same time as the thread. A Java Virtual Machine
stack stores frames (§2.6). A Java Virtual Machine stack is analogous
to the stack of a conventional language such as C: it holds local
variables and partial results, and plays a part in method invocation
and return. Because the Java Virtual Machine stack is never
manipulated directly except to push and pop frames, frames may be heap
allocated. The memory for a Java Virtual Machine stack does not need
to be contiguous.
In the First Edition of The Java® Virtual Machine Specification, the
Java Virtual Machine stack was known as the Java stack.
This specification permits Java Virtual Machine stacks either to be of
a fixed size or to dynamically expand and contract as required by the
computation. If the Java Virtual Machine stacks are of a fixed size,
the size of each Java Virtual Machine stack may be chosen
independently when that stack is created.
A Java Virtual Machine implementation may provide the programmer or
the user control over the initial size of Java Virtual Machine stacks,
as well as, in the case of dynamically expanding or contracting Java
Virtual Machine stacks, control over the maximum and minimum sizes.
The following exceptional conditions are associated with Java Virtual
Machine stacks:
If the computation in a thread requires a larger Java Virtual Machine
stack than is permitted, the Java Virtual Machine throws a
StackOverflowError.
If Java Virtual Machine stacks can be dynamically expanded, and
expansion is attempted but insufficient memory can be made available
to effect the expansion, or if insufficient memory can be made
available to create the initial Java Virtual Machine stack for a new
thread, the Java Virtual Machine throws an OutOfMemoryError.
An important point from this excerpt as far as your question is concerned:
- This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation.
Since you are not providing a stack size, JVM tries to dynamically expand the stack size as the function gets called recursively needing more stack memory. In each run, it may find different amount of dynamic memory for its stack depending on the availability of memory on your computer at that point of run. This is the reason you see a different value for the number of iterations it takes before throwing the SO error. If you configure (using Xss<size>
JVM parameter) a smaller stack size to your program, you should see mostly identical number of recursions before the SO error.
add a comment |
The JVM specs very nicely explain its behavior related to stack;
Each Java Virtual Machine thread has a private Java Virtual Machine
stack, created at the same time as the thread. A Java Virtual Machine
stack stores frames (§2.6). A Java Virtual Machine stack is analogous
to the stack of a conventional language such as C: it holds local
variables and partial results, and plays a part in method invocation
and return. Because the Java Virtual Machine stack is never
manipulated directly except to push and pop frames, frames may be heap
allocated. The memory for a Java Virtual Machine stack does not need
to be contiguous.
In the First Edition of The Java® Virtual Machine Specification, the
Java Virtual Machine stack was known as the Java stack.
This specification permits Java Virtual Machine stacks either to be of
a fixed size or to dynamically expand and contract as required by the
computation. If the Java Virtual Machine stacks are of a fixed size,
the size of each Java Virtual Machine stack may be chosen
independently when that stack is created.
A Java Virtual Machine implementation may provide the programmer or
the user control over the initial size of Java Virtual Machine stacks,
as well as, in the case of dynamically expanding or contracting Java
Virtual Machine stacks, control over the maximum and minimum sizes.
The following exceptional conditions are associated with Java Virtual
Machine stacks:
If the computation in a thread requires a larger Java Virtual Machine
stack than is permitted, the Java Virtual Machine throws a
StackOverflowError.
If Java Virtual Machine stacks can be dynamically expanded, and
expansion is attempted but insufficient memory can be made available
to effect the expansion, or if insufficient memory can be made
available to create the initial Java Virtual Machine stack for a new
thread, the Java Virtual Machine throws an OutOfMemoryError.
An important point from this excerpt as far as your question is concerned:
- This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation.
Since you are not providing a stack size, JVM tries to dynamically expand the stack size as the function gets called recursively needing more stack memory. In each run, it may find different amount of dynamic memory for its stack depending on the availability of memory on your computer at that point of run. This is the reason you see a different value for the number of iterations it takes before throwing the SO error. If you configure (using Xss<size>
JVM parameter) a smaller stack size to your program, you should see mostly identical number of recursions before the SO error.
The JVM specs very nicely explain its behavior related to stack;
Each Java Virtual Machine thread has a private Java Virtual Machine
stack, created at the same time as the thread. A Java Virtual Machine
stack stores frames (§2.6). A Java Virtual Machine stack is analogous
to the stack of a conventional language such as C: it holds local
variables and partial results, and plays a part in method invocation
and return. Because the Java Virtual Machine stack is never
manipulated directly except to push and pop frames, frames may be heap
allocated. The memory for a Java Virtual Machine stack does not need
to be contiguous.
In the First Edition of The Java® Virtual Machine Specification, the
Java Virtual Machine stack was known as the Java stack.
This specification permits Java Virtual Machine stacks either to be of
a fixed size or to dynamically expand and contract as required by the
computation. If the Java Virtual Machine stacks are of a fixed size,
the size of each Java Virtual Machine stack may be chosen
independently when that stack is created.
A Java Virtual Machine implementation may provide the programmer or
the user control over the initial size of Java Virtual Machine stacks,
as well as, in the case of dynamically expanding or contracting Java
Virtual Machine stacks, control over the maximum and minimum sizes.
The following exceptional conditions are associated with Java Virtual
Machine stacks:
If the computation in a thread requires a larger Java Virtual Machine
stack than is permitted, the Java Virtual Machine throws a
StackOverflowError.
If Java Virtual Machine stacks can be dynamically expanded, and
expansion is attempted but insufficient memory can be made available
to effect the expansion, or if insufficient memory can be made
available to create the initial Java Virtual Machine stack for a new
thread, the Java Virtual Machine throws an OutOfMemoryError.
An important point from this excerpt as far as your question is concerned:
- This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation.
Since you are not providing a stack size, JVM tries to dynamically expand the stack size as the function gets called recursively needing more stack memory. In each run, it may find different amount of dynamic memory for its stack depending on the availability of memory on your computer at that point of run. This is the reason you see a different value for the number of iterations it takes before throwing the SO error. If you configure (using Xss<size>
JVM parameter) a smaller stack size to your program, you should see mostly identical number of recursions before the SO error.
answered 8 hours ago
VHSVHS
7,02931028
7,02931028
add a comment |
add a comment |
Might be related to how much real memory the computer can allocate to the program, while other programs and process are running in the computer
add a comment |
Might be related to how much real memory the computer can allocate to the program, while other programs and process are running in the computer
add a comment |
Might be related to how much real memory the computer can allocate to the program, while other programs and process are running in the computer
Might be related to how much real memory the computer can allocate to the program, while other programs and process are running in the computer
answered 8 hours ago
riorioriorio
1,90031134
1,90031134
add a comment |
add a comment |
StackOverflowError is a error. As a error, is related to the JVM (a error is not a Exception!).
This error occurs when your stack (or method execution stack) collides with your heap size (JVM's memory).
The size of JVM's heap can be defined, but from your stack no.
add a comment |
StackOverflowError is a error. As a error, is related to the JVM (a error is not a Exception!).
This error occurs when your stack (or method execution stack) collides with your heap size (JVM's memory).
The size of JVM's heap can be defined, but from your stack no.
add a comment |
StackOverflowError is a error. As a error, is related to the JVM (a error is not a Exception!).
This error occurs when your stack (or method execution stack) collides with your heap size (JVM's memory).
The size of JVM's heap can be defined, but from your stack no.
StackOverflowError is a error. As a error, is related to the JVM (a error is not a Exception!).
This error occurs when your stack (or method execution stack) collides with your heap size (JVM's memory).
The size of JVM's heap can be defined, but from your stack no.
answered 8 hours ago
DoYaThingDoYaThing
606
606
add a comment |
add a comment |
So as others have pointed out you may have to look into what jvm is beings used and from there it might also be a good exercise to know what garbage collector (how often gc is being called ) is being used as this may give you a deeper understanding not only about stack overflow error but how generally Java works. And if really keen you could implement your own small JVM and may be with a better scheme.
add a comment |
So as others have pointed out you may have to look into what jvm is beings used and from there it might also be a good exercise to know what garbage collector (how often gc is being called ) is being used as this may give you a deeper understanding not only about stack overflow error but how generally Java works. And if really keen you could implement your own small JVM and may be with a better scheme.
add a comment |
So as others have pointed out you may have to look into what jvm is beings used and from there it might also be a good exercise to know what garbage collector (how often gc is being called ) is being used as this may give you a deeper understanding not only about stack overflow error but how generally Java works. And if really keen you could implement your own small JVM and may be with a better scheme.
So as others have pointed out you may have to look into what jvm is beings used and from there it might also be a good exercise to know what garbage collector (how often gc is being called ) is being used as this may give you a deeper understanding not only about stack overflow error but how generally Java works. And if really keen you could implement your own small JVM and may be with a better scheme.
answered 8 hours ago
briantaurostack7briantaurostack7
2911726
2911726
add a comment |
add a comment |
StackOverflowError
is thrown, when stack (part of memory, where method execution stack is stored) collides with heap (memory, that allocates objects, primitives etc.). You cannot predict, when the error is thrown, because the size of stack can be dynamic unless specified by -Xss
flag. That's why there is no fixed method execution depth, that causes StackOverflowError
.
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the-Xss
command line option
– David Soroko
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.
– David Soroko
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
add a comment |
StackOverflowError
is thrown, when stack (part of memory, where method execution stack is stored) collides with heap (memory, that allocates objects, primitives etc.). You cannot predict, when the error is thrown, because the size of stack can be dynamic unless specified by -Xss
flag. That's why there is no fixed method execution depth, that causes StackOverflowError
.
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the-Xss
command line option
– David Soroko
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.
– David Soroko
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
add a comment |
StackOverflowError
is thrown, when stack (part of memory, where method execution stack is stored) collides with heap (memory, that allocates objects, primitives etc.). You cannot predict, when the error is thrown, because the size of stack can be dynamic unless specified by -Xss
flag. That's why there is no fixed method execution depth, that causes StackOverflowError
.
StackOverflowError
is thrown, when stack (part of memory, where method execution stack is stored) collides with heap (memory, that allocates objects, primitives etc.). You cannot predict, when the error is thrown, because the size of stack can be dynamic unless specified by -Xss
flag. That's why there is no fixed method execution depth, that causes StackOverflowError
.
edited 5 hours ago
answered 8 hours ago
AndronicusAndronicus
4,36121430
4,36121430
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the-Xss
command line option
– David Soroko
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.
– David Soroko
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
add a comment |
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the-Xss
command line option
– David Soroko
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.
– David Soroko
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the
-Xss
command line option– David Soroko
8 hours ago
This is quite wrong, nothing collides with anything. The OP's program runs out of stack space which which has a default value and can be explicitly set ising the
-Xss
command line option– David Soroko
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
8 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on
-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.– David Soroko
5 hours ago
Without referring to other answers on SO, can you explain what "stack collides with heap" actually means? After reading the documentation on
-Xss
here docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html - please revisit your "You cannot predict..." remark.– David Soroko
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
@DavidSoroko edited
– Andronicus
5 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55108159%2fwhy-does-a-recursive-function-stop-on-random-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
8 hours ago
It looks like the exception happens during println and the string handling, could it depend on how/when garbage collection occurs?
– Joakim Danielson
8 hours ago