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. Disposing generic lists

Disposing generic lists

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 4 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.
  • K Offline
    K Offline
    kensai
    wrote on last edited by
    #1

    How do you dispose a generic list? Does myList = null solve the problem or does this only remove the reference to the instance and wait for the GC?

    P D C 3 Replies Last reply
    0
    • K kensai

      How do you dispose a generic list? Does myList = null solve the problem or does this only remove the reference to the instance and wait for the GC?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      In general, you should wait for the garbage collector to clear up resources.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      1 Reply Last reply
      0
      • K kensai

        How do you dispose a generic list? Does myList = null solve the problem or does this only remove the reference to the instance and wait for the GC?

        D Offline
        D Offline
        Daniel Grunwald
        wrote on last edited by
        #3

        Disposing only cleans up the unmanaged resources held by the object. The object itself can only be cleaned up by the GC.

        1 Reply Last reply
        0
        • K kensai

          How do you dispose a generic list? Does myList = null solve the problem or does this only remove the reference to the instance and wait for the GC?

          C Offline
          C Offline
          c2423
          wrote on last edited by
          #4

          kensai wrote:

          does this only remove the reference to the instance and wait for the GC

          Yes, that is correct. If you are completely desperate to get the memory back however, it is possible to force the garbage collection afterwards (however I wouldn't reccomend it unless you are having *severe* problems without) Chris

          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