0
A process is a method or it can be other things? Can you give me an example of stack overflow error?
When a process starts, it get a default stack size which is fixed for each process. Under abnormal condition, the stack limit exceeds. This is know as stack overflow.
4 Respostas
+ 3
Hichem GOUIA Infinite loop is not necessarily an stack overflow error. If you don't create new variables each time the loop runs, then no memory gets used up. So it can run for ever, without an error.
Infinite recursion is necessarily an stack overflow error. During a function call, some memory is allocated to store the parameters, return address, etc.
During infinite recursion, all the stack memory gets exhausted and thus the JVM gives the error. I
Stack Overflow mostly occurs in cases as shown by my code. But it can occur in other cases where the stack memory is used up.
Another example is, one class calling the constructor of other class and the other class calls the constructor of the first class. (When both the objects depend on each other). This can also produce the error. (It is similar to recursion. but it's two constructors calling each other infinitely)
If you declare too many local variables which take up stack memory, this can also happen.
+ 4
Stack overflow is caused by something which takes up all of the stack memory. Here is an example of an stack overflow error which is caused by a recursive function. I catch the Error and print it.
https://code.sololearn.com/c6Rn3wMu38z9/#java
0
Tejaswi Hegde infinite loop is it an example of stack overflow error?
0
Well explained my friend 😊
Thanks a lot