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. Other Discussions
  3. The Insider News
  4. Unlocking the Secrets of Managed memory: Dive into event handler leak insights!

Unlocking the Secrets of Managed memory: Dive into event handler leak insights!

Scheduled Pinned Locked Moved The Insider News
csharpvisual-studiowpfcomperformance
3 Posts 3 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
    Kent Sharkey
    wrote on last edited by
    #1

    Visual Studio[^]:

    Event handler leaks have been around for a long time, and they are one of the peskiest issues WPF (Windows Presentation Foundation) developers regularly deal with.

    But .NET *never* leaks memory, right?

    T 1 Reply Last reply
    0
    • K Kent Sharkey

      Visual Studio[^]:

      Event handler leaks have been around for a long time, and they are one of the peskiest issues WPF (Windows Presentation Foundation) developers regularly deal with.

      But .NET *never* leaks memory, right?

      T Offline
      T Offline
      trønderen
      wrote on last edited by
      #2

      The problem is that the memory isn't "leaked" if someone, or anyone, has a reference to it. The publisher / event has. If .net decided to garbage collect the subscriber, the event would be left with a (non-null) invalid pointer. As soon as the event (or rather: the last event) referencing the subscriber, dotNet would garbage collect it. I really would feel uncomfortable with dotNet garbage collecting an object still referenced.

      O 1 Reply Last reply
      0
      • T trønderen

        The problem is that the memory isn't "leaked" if someone, or anyone, has a reference to it. The publisher / event has. If .net decided to garbage collect the subscriber, the event would be left with a (non-null) invalid pointer. As soon as the event (or rather: the last event) referencing the subscriber, dotNet would garbage collect it. I really would feel uncomfortable with dotNet garbage collecting an object still referenced.

        O Offline
        O Offline
        obermd
        wrote on last edited by
        #3

        I was going to post this. The real issue here isn't a memory management leak, it's a failure to reclaim a counted reference item, which you don't want to do as long as there's a reference to it.

        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