Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
how can i handle stack overflow exception in my game it occures when i play the game plz reply asap possible?
Well, to be blunt, you should probably not try to handle a Stack Overflow exception.
In some cases, you can't execute code in response to a stack overflow exception, since that code requires stack space, which is unavailable, hence double-fault.
Instead, you should change the code so as to avoid it completely.
This might mean changing your algorithm to some other algorithm, or possibly implementing the stack-based recursion in your own stack and switch to a loop instead.
try
{
//your work
}
catch(StackOverflowException ex)
{
// handle it
}
Stack overflow is most often related to recursive calls, and not the gc.
GC would throw you an out of memory exception.
public static void main(String args[])
{
try
{
LongRecursiveMethodOrSomethingLikeThat();
} catch(StackOverflowError t) {
// Generic catch// catch(Error e)
// anything: catch(Throwable t)
System.out.println("Error:"+t);
t.printStackTrace();
}
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 months ago.
Improve this question
I am trying to run a simple hello world program on the Rust Playground:
fn main() {
println!("hello");
}
But all I get is an error:
Response was not JSON: SyntaxError: The string did not match the expected pattern.
What is going on?
This appears to be the symptomatic message displayed if the server-side of the Rust Playground is unresponsive, likely due to either updates or overloaded usage. There isn't much you can do beyond waiting for it to become responsive.
There is a mirror site here (by the playground's primary developer).
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I faced a stack overflow problem in GDScript.
Debugger
(Code to reproduce :)
extends Node
class_name MatchSession
func add_child(ch, un=true):
add_child(ch, un)
if get_child_count() == 2:
_start_match_session()
In your code, add_child calls add_child recursively, no stop condition:
func add_child(ch, un=true):
add_child(ch, un) # <--
if get_child_count() == 2:
_start_match_session()
Note also that Node.add_child is not virtual. You are shadowing it. I suggest pick another name for your function.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I want to understand the implementation of top command in linux ie how it uses the procfs interface for displaying the top running processes.?what sources should i refer.
First, read carefully proc(5). Then study code of procps, and, as commented by tangrs, of unixtop, i.e. top-3.7.tar.gz
For example, your program might do
{ FILE* psf = fopen("/proc/self/statm", "r");
if (psf) {
int progsize = 0;
fscanf(psf, "%d", &progsize);
printf ("program size is %d pages\n", progsize);
fclose(psf);
} else perror("fopen /proc/self/statm");
}
to print its own program size. You could make it a function:
int get_my_program_size(void) {
int progsize = -1;
FILE* psf = fopen("/proc/self/statm", "r");
if (psf) {
fscanf(psf, "%d", &progsize);
fclose(psf);
} else perror("get_my_program_size /proc/self/statm");
return progsize;
}
This is really quick: no disk i/o is involved, since the /proc/ filesystem is a pseudo-filesystem and its file contents are computed on the fly and on demand. These pseudo-files (like /proc/1234/statm or /proc/1234/status etc....) should be read sequentially.
If you want user-mode CPU time, you could parse the 14th field (utime) of /proc/self/stat (or of /proc/1234/stat for the process of pid 1234). I leave that as an exercise to the reader....
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Here is my program
function say(word) {
console.log(word);
}
function execute(someFunction, value) {
someFunction(value);
}
execute(say, "Hello");
How the value is getting printed through someFunction(value);
Probably, you meant execute to be like this:
function execute(someFunction, value) {
someFunction(value);
}
As it is, your code just calls execute recursively, forever. (Well, until the stack overflows.)
word is not reserved.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Improve this question
How can I create an executable that keeps running and shows up in task manager, but does nothing? I need it for a program, I can use every language, or if it already exists it's better.
Thanks.
Here is a C code to do the job, you can use the thread sleep method to decrease the CPU load
#include<stdio.h>
int main()
{
char a;
while((a=getchar())!='z')// to quit the program when z is pressed
{
}
return 0;
}
Create a file with .cmd extension and write this into that file:
:BEGIN
GOTO BEGIN
You can double click on it, and call it from any programming language you want with this like code:
system("/path_to_your_code/your_file.cmd");
Here's a good example in C#
using System;
using System.Threading;
class Program {
static void Main() {
while(true) {
Thread.Sleep(100); // So we don't spam the CPU too much
}
}
}
Another example for an program you actually could quit without too much hassle.
It just waits for you to press Enter. :)
using System;
class Program {
static void Main() {
Console.ReadLine();
}
}