garbage collection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike J

    #1

    garbage collection

    i need a example of disposing() and or
    explicily kicking off the garbage collector

    thanks
    MJ


  • rowe_newsgroups

    #2
    Re: garbage collection

    On May 11, 10:07 am, "Mike J" <vettes_n_j...@ sbcglobal.netwr ote:
    i need a example of disposing() and or
    explicily kicking off the garbage collector
    >
    thanks
    MJ
    i need a example of disposing()
    MyDisposableObj ect.Dispose()

    or

    Using (MyDisposableOb ject)
    ....
    End Using
    and or explicily kicking off the garbage collector
    GC.Collect()

    Please note that it is almost always a terrible idea to force the GC
    to collect, especially if you are disposing of your objects correctly.
    Please search this newsgroup (and/or related newsgroups) for a full
    overview of why this is a bad idea.

    Thanks,

    Seth Rowe

    Comment

    • Robin Tucker

      #3
      Re: garbage collection


      Hi,


      According to a Jeffery Richter Geekspeak web-cast I listened to recently,
      one of the reasons is that it will effectively reset the GC statistics on
      object lifetimes, or rather make them incorrect. The GC maintains
      information about object lifetimes in order to more efficiently dispose of
      objects depending on how long it expects them to live. Anyway there is
      almost never any good reason to force a collect.

      The OP should look up the IDisposable pattern (which Richter actually hates,
      even though he coded it!).



      Robin


      Comment

      • Michel Posseth  [MCP]

        #4
        Re: garbage collection

        In the class you want to enforce

        implements IDisposable '---- press enter after this line and all code wil be
        generated for you

        now explicitly dispose of anny sub objects in the interface signature

        end use your class with the using keyword in the rest of your project





        "Robin Tucker" <rtgroups@hotma il.co.ukschreef in bericht
        news:f222pl$jae $1$8300dec7@new s.demon.co.uk.. .
        >
        Hi,
        >
        >
        According to a Jeffery Richter Geekspeak web-cast I listened to recently,
        one of the reasons is that it will effectively reset the GC statistics on
        object lifetimes, or rather make them incorrect. The GC maintains
        information about object lifetimes in order to more efficiently dispose of
        objects depending on how long it expects them to live. Anyway there is
        almost never any good reason to force a collect.
        >
        The OP should look up the IDisposable pattern (which Richter actually
        hates, even though he coded it!).
        >
        >
        >
        Robin
        >

        Comment

        Working...