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. Visual Basic
  4. Disposing all objects

Disposing all objects

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
7 Posts 6 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.
  • G Offline
    G Offline
    Gagan 20
    wrote on last edited by
    #1

    I am creating a program in VB.net (VS2005) I want to know that how to dispose all objects used in my program while closing the program. Thanks. Gagan

    D D L 3 Replies Last reply
    0
    • G Gagan 20

      I am creating a program in VB.net (VS2005) I want to know that how to dispose all objects used in my program while closing the program. Thanks. Gagan

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You enumerate through your objects and call Dispose on them. Seriously, your question about shutting down is not answerable because we have no idea what your code is doing, how the app is written, what your code does in the event of a shutdown request, ... What is the main purpose of the app and how is the engine that provides this functionality written??

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      1 Reply Last reply
      0
      • G Gagan 20

        I am creating a program in VB.net (VS2005) I want to know that how to dispose all objects used in my program while closing the program. Thanks. Gagan

        D Offline
        D Offline
        David Mujica
        wrote on last edited by
        #3

        Some objects have a .Dispose method which you can call. Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced. For example: myObj.dispose() ' only if supported myObj = nothing ' indicate that the object is no longer referenced

        L 1 Reply Last reply
        0
        • D David Mujica

          Some objects have a .Dispose method which you can call. Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced. For example: myObj.dispose() ' only if supported myObj = nothing ' indicate that the object is no longer referenced

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          David Mujica wrote:

          Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced.

          that is completely irrelevant when the app is about to shut down as the OP stated. :)

          Luc Pattyn


          I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


          1 Reply Last reply
          0
          • G Gagan 20

            I am creating a program in VB.net (VS2005) I want to know that how to dispose all objects used in my program while closing the program. Thanks. Gagan

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            When an app shuts down, the Operating System recovers memory allotted to that app. So you don't have to worry about it. Modern operating systems (including Windows) are pre-emptive, i.e., they don't need the permission or co-operation of the applications to recover memory.

            P 1 Reply Last reply
            0
            • L Lost User

              When an app shuts down, the Operating System recovers memory allotted to that app. So you don't have to worry about it. Modern operating systems (including Windows) are pre-emptive, i.e., they don't need the permission or co-operation of the applications to recover memory.

              P Offline
              P Offline
              Paulo Zemek
              wrote on last edited by
              #6

              Also, all .Net finalizers are run while the application shuts down.

              L 1 Reply Last reply
              0
              • P Paulo Zemek

                Also, all .Net finalizers are run while the application shuts down.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Not necessarily. The runtime host can decide whether to run finalizers or not during application shutdown.

                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