Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8163517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:04:44+00:00 2026-06-06T19:04:44+00:00

Possible Duplicate: Runtime exception, recursion too deep I’m getting a problem while developing a

  • 0

Possible Duplicate:
Runtime exception, recursion too deep

I’m getting a problem while developing a c#.net program and I’ve simplified it to a simple problem, I need to understand why does this code throw a stackoverflow exception if I call the function like this :

CheckFunc(16000);

but works fine if I call it like this

CheckFunc(1000);

here is the function :

private void CheckFunc(Int32 i)
{
    if (i == 0)
        MessageBox.Show("good");
    else
        CheckFunc(i - 1);
}

tried to make the code as simple as it can get…

I understand that there is a stack that gets overflowed but which stack ? How can I fix this ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:04:46+00:00Added an answer on June 6, 2026 at 7:04 pm

    The problem is indeed stack overflow.

    Why it happens:

    The stack is a special memory region, where there are a few things stored:

    • local variables for functions
    • function parameters
    • (most importantly) function return addresses. When you return from a function, this is how the processor knows where to get back.

    The problem is that this memory region is limited. Recursive calls will add a significant amount of data on this stack, quickly filling it.

    How to fix it:

    There are several ways:

    • reduce the number of variables, if you have a local array in a recursive function, you are looking for trouble.
    • reduce the number of parameters for the function (apparently not the case here)
    • reduce the number of recursive calls.

    If this is not enough, the only solution is to find an iterative solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Are .NET 4.0 Runtime slower than .NET 2.0 Runtime? Hello All, We
Possible Duplicate: How do I tell if a win32 application uses the .NET runtime
Possible Duplicate: How do I tell if a win32 application uses the .NET runtime
Possible Duplicate: Application Crashes With “Internal Error In The .NET Runtime” I have a
Possible Duplicate: Yield In VB.NET In C#, when writing a function that returns an
Possible Duplicate: Calling a method named “string” at runtime in Java and C I
Possible Duplicate: Compile-time and runtime casting c# As I understand it, the following code
Possible Duplicate: Execute another jar in a java program Basically I want to run
Possible Duplicate: question about missing element in array decrease runtime to O(n) An array
Possible Duplicate: Android RuntimeException: Unable to instantiate the service Problem: starting an IntentService generates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.