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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:15:27+00:00 2026-05-26T23:15:27+00:00

When I debug these lines of code, I can observe ms/ms2 are instances of

  • 0

When I debug these lines of code, I can observe ms/ms2 are instances of value type and they are allocated on stack, and o (boxed MyStruct instance) is reference type and is allocated in managed heap.

I can view the addresses of ms and ms2 from a Watch window in Visual Studio, they are 0x0024f104 and 0x0024f0f0, respectively. So the stack is growing DOWN towards the bottom of the address space. Since stack and heap grow towards each other, the address region for the managed heap should be below 0x0024f0f0. But the address of o is actually 0x01e9312c, which means the heap does not grow towards the stack (although I can observe when new objects are allocated in the heap, their addresses are indeed growing UP).

Can someone help to explain this?

MyStruct ms = new MyStruct(1, 2, 4, 8); //0x0024f104, 16 bytes for ms
Object o = ms;                          //0x0024f100, 4 bytes for variable o
MyStruct ms2 = (MyStruct)o;             //0x0024f0f0, 16 bytes for ms2
  • 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-26T23:15:27+00:00Added an answer on May 26, 2026 at 11:15 pm

    Stack and head growing towards each other was a concept valid some 30 years ago.

    Generally you don’t have to and should not care of where in memory an object is located.

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

Sidebar

Related Questions

Background There are several different debug flags you can use with the Visual Studio
Is there any way to debug what is going on after my .NET code
Is there a good way to debug exited with code 5 runtime error on
I have a few simple lines of code (below). [bp] indicates a breakpoint. for(int
Sorry I can't be specific with code, but the problems I am seeing are
look at these code: public static String get(String url, Properties parameters) throws MalformedURLException, IOException{
First let me say that I can remote debug a release build on the
I would like to debug some templated code to understand it better. Unfortunately I'm
I am writing some debug code in a real-time javascript app. In the update
When i debug a programmer, I found too many lines useless info which appear

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.