Why does a recursive function stop on random numbers?2019 Community Moderator ElectionWhat is a StackOverflowError?Why does Java have transient fields?Changing main parameter typeWhy does this code using random strings print “hello world”?Is it possible to write a program in Java without main() using JDK 1.7 or higher?Size of String array passed as argument to main method in EclipseWhy the main method should be in staticJava - Method executed prior to Default ConstructorHello,How can i add two panels in one frame?When use java regular-expression pattern.matcher(), source does not match regex.But, my hope result is ,source matches regexWould it make any difference giving arguments using scanner class instead of command line arguments?
Good for you! in Russian
Do f-stop and exposure time perfectly cancel?
Vocabulary for giving just numbers, not a full answer
List elements digit difference sort
Was Luke Skywalker the leader of the Rebel forces on Hoth?
If I receive an SOS signal, what is the proper response?
Recommendation letter by significant other if you worked with them professionally?
Does this video of collapsing warehouse shelves show a real incident?
Virginia employer terminated employee and wants signing bonus returned
NASA's RS-25 Engines shut down time
How does NOW work?
How do I express some one as a black person?
What wound would be of little consequence to a biped but terrible for a quadruped?
Makefile strange variable substitution
finite abelian groups tensor product.
Declaring and defining template, and specialising them
What is the magic ball of every day?
Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?
Signed and unsigned numbers
How can I get players to stop ignoring or overlooking the plot hooks I'm giving them?
Single word request: Harming the benefactor
PTIJ: Should I kill my computer after installing software?
Shifting between bemols (flats) and diesis (sharps)in the key signature
Do I really need to have a scientific explanation for my premise?
Why does a recursive function stop on random numbers?
2019 Community Moderator ElectionWhat is a StackOverflowError?Why does Java have transient fields?Changing main parameter typeWhy does this code using random strings print “hello world”?Is it possible to write a program in Java without main() using JDK 1.7 or higher?Size of String array passed as argument to main method in EclipseWhy the main method should be in staticJava - Method executed prior to Default ConstructorHello,How can i add two panels in one frame?When use java regular-expression pattern.matcher(), source does not match regex.But, my hope result is ,source matches regexWould it make any difference giving arguments using scanner class instead of command line arguments?
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
5 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
5 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 5 hours ago
AfterShock360
asked 5 hours ago
AfterShock360AfterShock360
537
537
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
5 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
5 hours ago
add a comment |
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
5 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
5 hours ago
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
5 hours ago
Do this number changes if setting stack size using -Xss command line parameter?
– cesarse
5 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
5 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
5 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
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
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
2 hours ago
@DavidSoroko edited
– Andronicus
2 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 5 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 5 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 5 hours ago
DoYaThingDoYaThing
506
506
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 5 hours ago
briantaurostack7briantaurostack7
2811726
2811726
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
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
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
2 hours ago
@DavidSoroko edited
– Andronicus
2 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
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
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
2 hours ago
@DavidSoroko edited
– Andronicus
2 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 2 hours ago
answered 5 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
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
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
2 hours ago
@DavidSoroko edited
– Andronicus
2 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
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
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
2 hours ago
@DavidSoroko edited
– Andronicus
2 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
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
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
5 hours ago
@DavidSoroko here is a smilar explanation: stackoverflow.com/questions/214741/what-is-a-stackoverflowerror. However Op didn't set stack size
– Andronicus
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
2 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
2 hours ago
@DavidSoroko edited
– Andronicus
2 hours ago
@DavidSoroko edited
– Andronicus
2 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
5 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
5 hours ago