Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Memory Consumption

Memory Consumption

Scheduled Pinned Locked Moved C#
performance
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abcurl
    wrote on last edited by
    #1

    string str = null; can u tell, In the above line of code, what shall be teh memory consumption by the variable str

    R 1 Reply Last reply
    0
    • A abcurl

      string str = null; can u tell, In the above line of code, what shall be teh memory consumption by the variable str

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      Well, str is a reference type which doesn't reference anything, so it will be just the size of reference itself. I think this will be 4 bytes for the reference itself, and a further 8 for synchronisation and other .NET internal stuff. So, likely 12 bytes.

      Regards, Rob Philpott.

      A 1 Reply Last reply
      0
      • R Rob Philpott

        Well, str is a reference type which doesn't reference anything, so it will be just the size of reference itself. I think this will be 4 bytes for the reference itself, and a further 8 for synchronisation and other .NET internal stuff. So, likely 12 bytes.

        Regards, Rob Philpott.

        A Offline
        A Offline
        abcurl
        wrote on last edited by
        #3

        Rob Philpott wrote:

        and a further 8 for synchronisation and other .NET internal stuff.

        Can u please tell where should i read the detailed meaning of the above quoted line ?

        R 2 Replies Last reply
        0
        • A abcurl

          Rob Philpott wrote:

          and a further 8 for synchronisation and other .NET internal stuff.

          Can u please tell where should i read the detailed meaning of the above quoted line ?

          R Offline
          R Offline
          Rob Philpott
          wrote on last edited by
          #4

          Actually, I got that wrong. The extra 8 bytes would be on the heap if your reference was not null. So, just 4 bytes on a 32bit machine. Trying to find a good reference for this stuff now.

          Regards, Rob Philpott.

          1 Reply Last reply
          0
          • A abcurl

            Rob Philpott wrote:

            and a further 8 for synchronisation and other .NET internal stuff.

            Can u please tell where should i read the detailed meaning of the above quoted line ?

            R Offline
            R Offline
            Rob Philpott
            wrote on last edited by
            #5

            Can't find anything on the net I'm afraid. I'm sure there's lots out there if you look around though. Also, consider reading one of Jeffrey Richters books - they are excellent on this sort of stuff.

            Regards, Rob Philpott.

            A 1 Reply Last reply
            0
            • R Rob Philpott

              Can't find anything on the net I'm afraid. I'm sure there's lots out there if you look around though. Also, consider reading one of Jeffrey Richters books - they are excellent on this sort of stuff.

              Regards, Rob Philpott.

              A Offline
              A Offline
              abcurl
              wrote on last edited by
              #6

              Thanks a lot.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups