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. setting an object to null, what happens?

setting an object to null, what happens?

Scheduled Pinned Locked Moved C#
performancequestion
3 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.
  • D Offline
    D Offline
    devin123
    wrote on last edited by
    #1

    Hi, After I am done with the object, when I set that object to null, what I am doing there. (Is it, I am setting manually no references to the object or I am reclaming the memory used by the object or I am doing both) Thanks Devin.

    C 1 Reply Last reply
    0
    • D devin123

      Hi, After I am done with the object, when I set that object to null, what I am doing there. (Is it, I am setting manually no references to the object or I am reclaming the memory used by the object or I am doing both) Thanks Devin.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      devin123 wrote: After I am done with the object, when I set that object to null, what I am doing there. You are setting the reference to the object to null, not the object itself. If there are no references to an object the garbage collector can remove the object from memory. If the reference is a local variable then when the method goes out of scope the reference will no longer exist and the object (assuming no other references) will get cleaned up. Does this help?


      My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      D 1 Reply Last reply
      0
      • C Colin Angus Mackay

        devin123 wrote: After I am done with the object, when I set that object to null, what I am doing there. You are setting the reference to the object to null, not the object itself. If there are no references to an object the garbage collector can remove the object from memory. If the reference is a local variable then when the method goes out of scope the reference will no longer exist and the object (assuming no other references) will get cleaned up. Does this help?


        My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

        D Offline
        D Offline
        devin123
        wrote on last edited by
        #3

        That helped me.

        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