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. GDI+ and memory leaks

GDI+ and memory leaks

Scheduled Pinned Locked Moved .NET (Core and Framework)
graphicswinformsperformancehelpquestion
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.
  • M Offline
    M Offline
    mikelb
    wrote on last edited by
    #1

    I have some custom drawing code that I'm doing in my application. I made sure to use the using statement or explicity call dispose on all the brushes and pens that I'm using to make sure that I don't have any memory leaks. My problem is that if I start the application and move the mouse around to cause the drawing to occur then I see in the task manager that I slowly eat up more and more memory, 20-60k at a time. If I don't change a single line of code but put in a GC.Collect() at the end of my drawing then I see that no extra memory is consumed. I've left the application running for a while and I don't see the memory being released w/o the GC.Collect(). Am I supposed to just trust that everything is going ok under the covers and that at some point Garbage collection will get it? If I do this and I give someone here my application won't they assume I have a memory leak? Thanks, Michael

    I S 2 Replies Last reply
    0
    • M mikelb

      I have some custom drawing code that I'm doing in my application. I made sure to use the using statement or explicity call dispose on all the brushes and pens that I'm using to make sure that I don't have any memory leaks. My problem is that if I start the application and move the mouse around to cause the drawing to occur then I see in the task manager that I slowly eat up more and more memory, 20-60k at a time. If I don't change a single line of code but put in a GC.Collect() at the end of my drawing then I see that no extra memory is consumed. I've left the application running for a while and I don't see the memory being released w/o the GC.Collect(). Am I supposed to just trust that everything is going ok under the covers and that at some point Garbage collection will get it? If I do this and I give someone here my application won't they assume I have a memory leak? Thanks, Michael

      I Offline
      I Offline
      igor1960
      wrote on last edited by
      #2

      Am I supposed to just trust that everything is going ok under the covers and that at some point Garbage collection will get it? Yes, I suppose you do have to trust -- unless otherwise.... "...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..." Me

      1 Reply Last reply
      0
      • M mikelb

        I have some custom drawing code that I'm doing in my application. I made sure to use the using statement or explicity call dispose on all the brushes and pens that I'm using to make sure that I don't have any memory leaks. My problem is that if I start the application and move the mouse around to cause the drawing to occur then I see in the task manager that I slowly eat up more and more memory, 20-60k at a time. If I don't change a single line of code but put in a GC.Collect() at the end of my drawing then I see that no extra memory is consumed. I've left the application running for a while and I don't see the memory being released w/o the GC.Collect(). Am I supposed to just trust that everything is going ok under the covers and that at some point Garbage collection will get it? If I do this and I give someone here my application won't they assume I have a memory leak? Thanks, Michael

        S Offline
        S Offline
        Stephane Rodriguez
        wrote on last edited by
        #3

        Consider a separate GDI profiler, like this one[^]. The fact that GC.Collect() affects the amount of used handles is quite normal. Would you be surprised if you sent yourself a WM_CLOSE message that your application got finished?


        RSS feed

        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