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. Manually disposing objects with API

Manually disposing objects with API

Scheduled Pinned Locked Moved Visual Basic
jsonquestion
4 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.
  • N Offline
    N Offline
    Name Removed
    wrote on last edited by
    #1

    Is there any way to manually dispose of an object using Windows API?

    D 1 Reply Last reply
    0
    • N Name Removed

      Is there any way to manually dispose of an object using Windows API?

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

      Manually dispose of a managed (.NET Framework) object using the Windows API? No, you can't. This must be done by the CLR Garbage Collector otherwise you'll corrupt the CLR runtime and crash it. What's wrong with the .Dispose() method? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      N 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Manually dispose of a managed (.NET Framework) object using the Windows API? No, you can't. This must be done by the CLR Garbage Collector otherwise you'll corrupt the CLR runtime and crash it. What's wrong with the .Dispose() method? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        N Offline
        N Offline
        Name Removed
        wrote on last edited by
        #3

        Thanks. Dave Kreskowiak wrote: What's wrong with the .Dispose() method? I was using a System.Resources.ResourceSet object for a large resource file, and when I called it's .Dispose() or it's .Close() method, it wouldn't free the memory used by it, even after GC.Collect() on then next line. I finally figured out to assign the value Nothing to it, which freed the memory used by it. Kyle

        D 1 Reply Last reply
        0
        • N Name Removed

          Thanks. Dave Kreskowiak wrote: What's wrong with the .Dispose() method? I was using a System.Resources.ResourceSet object for a large resource file, and when I called it's .Dispose() or it's .Close() method, it wouldn't free the memory used by it, even after GC.Collect() on then next line. I finally figured out to assign the value Nothing to it, which freed the memory used by it. Kyle

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

          Kyle Edwards wrote: even after GC.Collect() on then next line Don't call the GC Collect method unless you specifically know what you doing and why. When the GC Collects, it has to wait for ALL threads running under the .NET Framework to pause. This CAN take a LOOOOOOONG time to do. Only when all the threads are paused can the GC safely do it's job. When it's done, all the threads are resumed. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          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