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. .NET (Core and Framework)
  4. .net memory leaks

.net memory leaks

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpvisual-studioperformance
5 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.
  • B Offline
    B Offline
    Bret Stern
    wrote on last edited by
    #1

    top right of form. Looks like memory is leaking. Don't rememebr vb6 doing this. Many thanks.

    M D 2 Replies Last reply
    0
    • B Bret Stern

      top right of form. Looks like memory is leaking. Don't rememebr vb6 doing this. Many thanks.

      M Offline
      M Offline
      MarkLTX
      wrote on last edited by
      #2

      My guess is that the memory usage hasn't grown enough to trigger the garbage collector. You could try calling Dispose() on the second window after it closes and see if that has any effect. You could also try "manually" invoking garbage collection after the second window closes (first setting any references to it to null).

      B 1 Reply Last reply
      0
      • B Bret Stern

        top right of form. Looks like memory is leaking. Don't rememebr vb6 doing this. Many thanks.

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

        Bret Stern wrote:

        watch memory in task manager),

        There's your first mistake. Task Manager is not showing you how much memory your application is using, but how much the .NET CLR has RESERVED for your application. Use the .NET Memory counters in PerfMon to find out how much memory your app is actually using. By reserved, I mean your application can free memory that it isn't using any more but that memory goes back the Managed Heap for future allocations. It will not be freed back to Windows unless the CLR deems that it doesn't need the memory or Windows starts to run low on memory and requests that the .NET CLR frees up whatever it can. The is a completely automatic process and the .NET Memory Manager does it's job very well. You do not need to worry about freeing up the memory yourself. Next, this depends on what you're using to show the second form. If you use the .ShowDialog() method on your form instance you MUST call Dispose() method on the form instance when you're done with the form. If you don't do this you WILL run into memory and handle issues, possibly running Windows out of resources. Oh, and do NOT call GC.Collect() unless you know exactly why you're doing it and understand completely the impacts on the GC. You can easily negatively impact the performance of your application by calling Collect unnecessarily.

        A guide to posting questions on CodeProject

        Click this: Asking questions is a skill. Seriously, do it.
        Dave Kreskowiak

        B 1 Reply Last reply
        0
        • D Dave Kreskowiak

          Bret Stern wrote:

          watch memory in task manager),

          There's your first mistake. Task Manager is not showing you how much memory your application is using, but how much the .NET CLR has RESERVED for your application. Use the .NET Memory counters in PerfMon to find out how much memory your app is actually using. By reserved, I mean your application can free memory that it isn't using any more but that memory goes back the Managed Heap for future allocations. It will not be freed back to Windows unless the CLR deems that it doesn't need the memory or Windows starts to run low on memory and requests that the .NET CLR frees up whatever it can. The is a completely automatic process and the .NET Memory Manager does it's job very well. You do not need to worry about freeing up the memory yourself. Next, this depends on what you're using to show the second form. If you use the .ShowDialog() method on your form instance you MUST call Dispose() method on the form instance when you're done with the form. If you don't do this you WILL run into memory and handle issues, possibly running Windows out of resources. Oh, and do NOT call GC.Collect() unless you know exactly why you're doing it and understand completely the impacts on the GC. You can easily negatively impact the performance of your application by calling Collect unnecessarily.

          A guide to posting questions on CodeProject

          Click this: Asking questions is a skill. Seriously, do it.
          Dave Kreskowiak

          B Offline
          B Offline
          Bret Stern
          wrote on last edited by
          #4

          Not use to the memory babysitting. Thanks for the explanations.

          1 Reply Last reply
          0
          • M MarkLTX

            My guess is that the memory usage hasn't grown enough to trigger the garbage collector. You could try calling Dispose() on the second window after it closes and see if that has any effect. You could also try "manually" invoking garbage collection after the second window closes (first setting any references to it to null).

            B Offline
            B Offline
            Bret Stern
            wrote on last edited by
            #5

            Thank you. Seem to remember something about garbage collection being automatic. The environment looks pretty slick. Should be lots of fun.

            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