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

  • Home
  • SEARCH
  • 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 6697299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:26:39+00:00 2026-05-26T06:26:39+00:00

Today i was reading a SO thread about array and its memory allocation. And

  • 0

Today i was reading a SO thread about array and its memory allocation. And i found an answer which was neatly explained and i must say its excellent.

But after reading that answer, i got few more questions which i kept asking myself about what i just read. So far still i am unable to answer it myself nor able to google it up. Hence i require your kind help in explaining those questions to me.

  1. Why is array getting created on heap when every of its content is
    getting stored on stack? Just 2 avoid boxing in case of value types?
  2. If above was true, then why array had 2 be created on heap first of all?

  3. When he said in his answer new int[100] is actually getting created on heap, is 400 (100 * 4) bytes getting allocated on heap?
    If so, why? because all the values are getting stored on stack

  4. If 1000 item array is created, then how on earth stack is enough to be stored? I know 1 MB is the size of the stack allocated. but in
    this case it will exceed. So whats the funda??

Please feel free to add your own questions or more info if you may have to 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-05-26T06:26:39+00:00Added an answer on May 26, 2026 at 6:26 am

    When we say array is allocated on heap it means the values will be in heap. Array values are not stored on stack. I think this answers all 3 questions.

    var myArray = new int[10];
    

    Above line creates myArray variable on stack but the memory of array is allocated on heap and so all values stored in it also go in heap.

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

Sidebar

Related Questions

On Proggit today I was reading the comment thread on a submission entitled, Why
While reading proggit today, I came upon this comment in a post about how
I was reading about self-referential has_many :through data situations today, because I'm trying to
I just began reading more about Markov Chain Generators today, and am really intrigued
I was reading today about researchers discovering that NVidia's Phys-X libraries use x87 FP
As you can see by reading my other thread today here , I'm having
I am about to upload my app today and remember reading something about giving
Today I stumbled about a Problem which seems to be a bug in the
Reading about the G.729 codec , I found this interesting tidbit about Comfort Noise
I started reading up about the NSFetchedResultsController today, but I've come across some confusing

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.