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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:48:40+00:00 2026-05-11T02:48:40+00:00

what is the memory overhead on the stack and heap of A versus B

  • 0

what is the memory overhead on the stack and heap of A versus B

A:

private string TestA() {      string a = _builder.Build();      return a;        } 

B:

private string TestB() {      return _builder.Build(); } 
  • 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. 2026-05-11T02:48:41+00:00Added an answer on May 11, 2026 at 2:48 am

    re the efficiency question; the two are identical, and in release mode will be reduced to the same thing. Either way, string is a reference-type, so the string itself is always on the heap. The only thing on the stack would be the reference to the string – a few bytes (no matter the string length).

    ‘do all local variables go on the stack’: no; there are two exceptions:

    • captured variables (anonymous methods / lambdas)
    • iterator blocks (yield return etc)

    In both cases, there is a compiler generated class behind the scenes:

    int i = 1; Action action = delegate {i++;}; action(); Console.WriteLine(i); 

    is similar to:

    class Foo {     public int i; // yes, a public field     public void SomeMethod() {i++;} } ... Foo foo = new Foo(); foo.i = 1; Action action = foo.SomeMethod; action(); Console.WriteLine(foo.i); 

    Hence i is on an object, hence on the heap.

    Iterator blocks work in a similar way, but with the state machine.

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

Sidebar

Related Questions

C#: Which uses more memory overhead? A string or a char holding a sequence
Possible Duplicate: Memory overhead of Java HashMap compared to ArrayList I try to search
I'm trying to get a handle on the amount of memory overhead associated with
Using groovy, would you expect better performance in terms of speed and memory overhead
Can anyone tell me what is the memory usage overhead associated with PHP opcode
In C++, what's the overhead (memory/cpu) associated with inheriting a base class that has
Is there any overhead using partial classes in case of memory, performance etc? If
Is there significant cpu/memory overhead associated with using automatic arrays with g++/Intel on 64-bit
I would like to ask about Memory Overhead in java, I have a large
Is there any performance or memory overhead using UIImage or UILabel or NSString in

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.