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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:01:38+00:00 2026-06-06T10:01:38+00:00

I’m looking into the memory model a little more and am struggling with understanding

  • 0

I’m looking into the memory model a little more and am struggling with understanding how many heap’s exist in a process.

So if we have 1 process with 5 threads in it, am I correct in saying that we’d have 5 stacks and 1 heap?

If so, can the threads access one another’s stacks (or is this exactly why they have separate Stacks, to prevent corruption), and if there’s just 1 heap, then obviously they all access this heap, hence the need for locking with multiple threads? Am I understanding this correctly?

  • 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-06T10:01:39+00:00Added an answer on June 6, 2026 at 10:01 am

    Yes, each thread has its own stack. That’s a hard necessity, the stack keeps track of where a method returns after it finishes, it stores the return address. Since each thread executes its own code, they need their own stack. Local variables and method arguments are stored there too, making them (usually) thread-safe.

    The number of heaps is a more involved detail. You are counting 1 for the garbage collected heap. That’s not entirely correct from an implementation point of view, the three generational heap plus the Large Object Heap are logically distinct heaps, adding that up to four. This implementation detail starts to matter when you allocate too much.

    Another one that you can’t entirely ignore in managed code is the heap that stores static variables. It is associated with the AppDomain, static variables live as long as the AppDomain lives. Commonly named “loader heap” in .NET literature. It actually consists of 3 heaps (high frequency, low frequency and stub heap), jitted code and type data is stored there too but that’s getting to the nitty gritty.

    Further down the ignore list are the heaps used by native code. Two of them are readily visible from the Marshal class. There’s a default process heap, Windows allocates from it, so does Marshal.AllocHGlobal(). And there’s a separate heap where COM stores data, Marshal.AllocCoTaskMem() allocates from it. Lastly any native code you interop with will have its own heap for its runtime support. The number of heaps used by that kind of code is bounded only by the number of native DLLs that get loaded into your process. All of these heaps exist, you barely ever deal with them directly.

    So, 10 heaps minimum.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have thousands of HTML files to process using Groovy/Java and I need to
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters

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.