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 7735367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:29:05+00:00 2026-06-01T07:29:05+00:00

I am curious whether it is possible to determine the maximum size that an

  • 0

I am curious whether it is possible to determine the maximum size that an array can have in C++.

    #include <iostream>

    using namespace std;

    #define MAX 2000000

    int main()
    {
      long array[MAX];
      cout << "Message" << endl;
      return 0;
    }

This compiles just fine, but then segfaults as soon as I run it (even though array isn’t actually referenced). I know it’s the array size too because if I change it to 1000000 it runs just fine.

So, is there some define somewhere or some way of having #define MAX MAX_ALLOWED_ARRAY_SIZE_FOR_MY_MACHINE_DEFINED_SOMEWHERE_FOR_ME?

I don’t actually need this for anything, this question is for curiosity’s sake.

  • 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-01T07:29:07+00:00Added an answer on June 1, 2026 at 7:29 am

    There isn’t a way to determine this statically, because the actual limit depends on how much stack space your thread has been given. You could create a new thread, give it 10 megabytes of stack, and you would be able to allocate a correspondingly larger local array.

    The amount you can allocate on the stack also depends on how much has already been used so far.

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

Sidebar

Related Questions

I have the following code which works as expected: #include <iostream> using namespace std;
I don't have a code example, but I'm curious whether it's possible to write
I'm curious as to whether one can define a Java class purely using a
I have been a curious , whether is this possible in SQL Here is
Although I'm doubtful, I'm curious as to whether it's possible to extract primitive-type template
Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses
I'm curious whether many of us who do design or take design decisions have
Just curious whether it's possible to mirror databases across versions.
I'm curious whether it's possible to use Google Maps Street View as a platform
I'm just curious about whether this is possible - I know how to download

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.