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. To find a memory leak

To find a memory leak

Scheduled Pinned Locked Moved Visual Basic
questioncsharpperformancehelp
3 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.
  • B Offline
    B Offline
    Bernhard Hofmann
    wrote on last edited by
    #1

    Has anyone else suffered a memory leak in their VB.NET programs? I have a few classes that are created when a form is created. The whole thing is quite complex and wasn't written by me. I would expect any class I create to be destroyed when the form is closed, but they all seem to sit around in memory. The garbage collector just seems to shuffle about all the time and not free the memory. Even when I do nothing in the application, the GC reports varying values for the GetTotalMemory() method. My problem is that I can't tell what is referencing the memory that can't be freed. A restart of the application is the only way to clear the memory at the moment. Any advice? I'm getting desparate! :confused:

    D 1 Reply Last reply
    0
    • B Bernhard Hofmann

      Has anyone else suffered a memory leak in their VB.NET programs? I have a few classes that are created when a form is created. The whole thing is quite complex and wasn't written by me. I would expect any class I create to be destroyed when the form is closed, but they all seem to sit around in memory. The garbage collector just seems to shuffle about all the time and not free the memory. Even when I do nothing in the application, the GC reports varying values for the GetTotalMemory() method. My problem is that I can't tell what is referencing the memory that can't be freed. A restart of the application is the only way to clear the memory at the moment. Any advice? I'm getting desparate! :confused:

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

      Google for '.NET Memory Profiler' or 'Allocation Profiler'. You'll find a bunch of them , some trial version, some shareware. I've used the Allocation Profiler from GotDotNet before with pretty good results, plus, you can get the source for it! RageInTheMachine9532

      B 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Google for '.NET Memory Profiler' or 'Allocation Profiler'. You'll find a bunch of them , some trial version, some shareware. I've used the Allocation Profiler from GotDotNet before with pretty good results, plus, you can get the source for it! RageInTheMachine9532

        B Offline
        B Offline
        Bernhard Hofmann
        wrote on last edited by
        #3

        I downloaded the trial of SciTech .NET Memory Profiler 2.0 (http://www.scitech.se/memprofiler/Default.htm). This tool helped me find the memory leak. FWIW: When I create an event handler for a multi-line text box, the form sits in memory after being closed. I removed the handlers and the form is removed! I've never seen anything like it. I have NO CODE in the handler, just this: Private Sub TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTextbox1.TextChanged End Sub And if I remove it, my 1K+ form will remove itself from memory. If the handler is in there, no number of GC.collect statements will free the damned thing. Garbage I say GARBAGE !!! Don't worry, nobody lives forever.

        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