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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:50:06+00:00 2026-06-14T19:50:06+00:00

VS memory profiler tells me that when I add a byte field to my

  • 0

VS memory profiler tells me that when I add a byte field to my class, it does not take any additional memory right at the start of application, but if it’s an int or object, it takes additional 4 bytes per instance.

Are there any other types, or can I create my own that don’t take up memory before assigned a value?
Also will the memory free up when the value becomes null (zero) again?

  • 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-14T19:50:08+00:00Added an answer on June 14, 2026 at 7:50 pm

    Memory on a 32-bit platform is typically allocated in allocation units of 4 bytes. I assume the .NET Runtime is doing just that.

    The C# compiler uses a layout that results in the smallest allocation size for a class/struct (unless you use annotations to indicate otherwise, which one would do e.g. when using interop to communicate with unmanaged code that lays out memory differently). That means that

    • 4 byte variables need only take one allocation unit
    • 2 short or ushort only take one allocation unit
    • If you have an int and then a byte, that byte will still trigger use of another allocation unit. You could then add up to 3 more byte variables without requiring another allocation unit.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CLR profiler does not seem to work with the Silverlight CLR. Does another memory
Possible Duplicate: Is there any working memory profiler for Python3 I have some script
I'm looking for a free code profiler (performance profiler, not a memory profiler) which
I have a loop variable that does not appear to be getting garbage collected
Are there any tools that can identify the total memory usage, cpu, and other
I'm looking for a good JavaScript Memory profiler, specifically one that targets IE. And
Possible Duplicate: Javascript memory profiler I like to know what variables take how much
Do you have any suggestion/idea of Memory profiler for Silverlight?
Is there such a thing as a Memory profiler for Iphones apps? I'd like
Today I was writing a little Memory Profiler for my code and for the

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.