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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:53:23+00:00 2026-06-03T02:53:23+00:00

I am new to coding C++ in Xcode as my framework so I would

  • 0

I am new to coding C++ in Xcode as my framework so I would like to ask a question that I believe is merely related to memory management

What I’m trying to achieve is that I try to create a matrix size 10000 x 10000 however even I do the proper coding(at least that’s what I believe) I just can’t get it to work, just pointing out the EXC_BAD_ACCESS error.

You can find my code in below. Is this an XCode-oriented error or I’ve done an obvious coding error?

#include <iostream>
using namespace std;

    int main(int argc, const char * argv[])
    {

        // insert code here...
        int matrix[10000][10000];
        for(int i=0;i<10000;i++)
            for(int j=0;j<10000;j++)
                matrix[i][j]=24;
        cout<<"Done"<<endl;
        return 0;
    }
  • 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-03T02:53:24+00:00Added an answer on June 3, 2026 at 2:53 am

    If Jesse Good posts his comment “int matrix[10000][10000]; looks like a stack overflow to me. ” as an answer, I’ll delete this.

    You should create an allocation of this size on the heap, rather than on the stack.

    Here’s the breakdown:

    400,000,000 bytes = 10000*10000*sizeof(int)
    

    One common way to overcome this problem by creating allocations on the heap would be:

    #include <iostream>
    #include <vector>
    
    int main(int argc, const char* argv[]) {
        std::vector<std::vector<int> > matrix(10000, std::vector<int>(10000, 24));
        cout<<"Done"<<endl;
        return 0;
    }
    

    Stack size is determined by the operating system, hardware, and other things. You may have less than one MB to work with, but not usually more than a few. Therefore, large stack allocations should be avoided.

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

Sidebar

Related Questions

I am new to coding and would just like to know a bit more
I am new to coding and would like to set this up in my
I'm fairly new to coding with Objective-C/Xcode, so I'm just trying my luck with
I'm completely new to coding - I can do some basic HTML. I'm trying
Im very new to all coding including jquery. I though this would have been
I'm new to Delphi coding and struggeling in reading .txt files. I am trying
I am quite new to Xcode coding and I have been using Storyboard for
I'm new to Xcode 4.2 and have a Storyboard array question. I'm doing a
we're trying to implement new coding style guidelines for our team, the php codesniffer
I'm new to coding in general, and I'm wanting to build a website that

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.