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. The Lounge
  3. New Windows bug causes GDI leaks in MFC apps

New Windows bug causes GDI leaks in MFC apps

Scheduled Pinned Locked Moved The Lounge
helpc++comgraphicsjson
23 Posts 14 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.
  • J Joshua Quick

    For all of you MFC developers out there busy trying to locate what's causing those recent GDI leaks in your app, take a look at this. It turns out running MFC apps on WinXP sp2 and Win2003 leaks GDI resources while XP themes are enabled. The bug report on Microsoft's site is dated this month, so it looks like a recent issue (otherwise I would have been pulling out hairs months ago). Here is their bug report. http://support.microsoft.com/?id=319740[^] I tell ya, this one was driving me nuts for the past week. Going over thousands of lines of code only to discover later that it's not my bug. So, I thought I'd be a good CP member and share this with the rest of you.

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #2

    Joshua Quick wrote:

    It turns out running MFC apps on WinXP sp2 and Win2003 leaks GDI resources while XP themes are enabled.

    Really? I thought MFC leaked resources, period. No wait, it's any Windows OS that leaks resources. No wait... Ah, heck, the only thing I can remember is to reboot my computer every day. ;P Marc My website Traceract Understanding Simple Data Binding Diary Of A CEO - Preface

    J 1 Reply Last reply
    0
    • J Joshua Quick

      For all of you MFC developers out there busy trying to locate what's causing those recent GDI leaks in your app, take a look at this. It turns out running MFC apps on WinXP sp2 and Win2003 leaks GDI resources while XP themes are enabled. The bug report on Microsoft's site is dated this month, so it looks like a recent issue (otherwise I would have been pulling out hairs months ago). Here is their bug report. http://support.microsoft.com/?id=319740[^] I tell ya, this one was driving me nuts for the past week. Going over thousands of lines of code only to discover later that it's not my bug. So, I thought I'd be a good CP member and share this with the rest of you.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #3

      Wow - given that W2000 kindly handles those sort of leaks ( so if you write on W2000, you need to test on W98 ), that's a bit of a doozie. Christian Graus - Microsoft MVP - C++

      J C 2 Replies Last reply
      0
      • C Christian Graus

        Wow - given that W2000 kindly handles those sort of leaks ( so if you write on W2000, you need to test on W98 ), that's a bit of a doozie. Christian Graus - Microsoft MVP - C++

        J Offline
        J Offline
        Joshua Quick
        wrote on last edited by
        #4

        Christian Graus wrote:

        that's a bit of a doozie.

        No kidding. Since my apps are designed to run 24/7/365, this issue is a big deal to me.

        1 Reply Last reply
        0
        • M Marc Clifton

          Joshua Quick wrote:

          It turns out running MFC apps on WinXP sp2 and Win2003 leaks GDI resources while XP themes are enabled.

          Really? I thought MFC leaked resources, period. No wait, it's any Windows OS that leaks resources. No wait... Ah, heck, the only thing I can remember is to reboot my computer every day. ;P Marc My website Traceract Understanding Simple Data Binding Diary Of A CEO - Preface

          J Offline
          J Offline
          Joshua Quick
          wrote on last edited by
          #5

          :-D

          1 Reply Last reply
          0
          • C Christian Graus

            Wow - given that W2000 kindly handles those sort of leaks ( so if you write on W2000, you need to test on W98 ), that's a bit of a doozie. Christian Graus - Microsoft MVP - C++

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #6

            Anyone remember the fun and games of Win95's GDI? cheers, Chris Maunder

            CodeProject.com : C++ MVP

            C M 2 Replies Last reply
            0
            • C Chris Maunder

              Anyone remember the fun and games of Win95's GDI? cheers, Chris Maunder

              CodeProject.com : C++ MVP

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #7

              Do you mean before Win98 added stuff like TransparentBlt ? Or just managing GDI handles in general ? Christian Graus - Microsoft MVP - C++

              C 1 Reply Last reply
              0
              • C Christian Graus

                Do you mean before Win98 added stuff like TransparentBlt ? Or just managing GDI handles in general ? Christian Graus - Microsoft MVP - C++

                C Offline
                C Offline
                Chris Maunder
                wrote on last edited by
                #8

                I mean that you were strictly limited in the number of GDI objects you could create (without releasing) before the system started refusing to grant you more. You quickly learned to check the return values of system calls :) cheers, Chris Maunder

                CodeProject.com : C++ MVP

                C R V J 4 Replies Last reply
                0
                • C Chris Maunder

                  I mean that you were strictly limited in the number of GDI objects you could create (without releasing) before the system started refusing to grant you more. You quickly learned to check the return values of system calls :) cheers, Chris Maunder

                  CodeProject.com : C++ MVP

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #9

                  Oh, OK. I didn't recall that, especially, but I believe you :-) Was the limit really small and then grew in W98 ? I did write a paint program for W95, but I developed it using W98 and then 2000. Christian Graus - Microsoft MVP - C++

                  J S L 3 Replies Last reply
                  0
                  • C Christian Graus

                    Oh, OK. I didn't recall that, especially, but I believe you :-) Was the limit really small and then grew in W98 ? I did write a paint program for W95, but I developed it using W98 and then 2000. Christian Graus - Microsoft MVP - C++

                    J Offline
                    J Offline
                    J Dunlap
                    wrote on last edited by
                    #10

                    Christian Graus wrote:

                    Was the limit really small and then grew in W98 ?

                    It was really small and didn't grow noticably in Win98 - at least it wasn't enough for me to notice much. All the Win9_x_ versions suffer from the fixed system resource problem. It's a nostalgic memory looking back, but I wouldn't return to those days. ;)

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      Oh, OK. I didn't recall that, especially, but I believe you :-) Was the limit really small and then grew in W98 ? I did write a paint program for W95, but I developed it using W98 and then 2000. Christian Graus - Microsoft MVP - C++

                      S Offline
                      S Offline
                      Shog9 0
                      wrote on last edited by
                      #11

                      Better! It was really small in W95 and W98, but the shell itself used more in W98, so you essentially started out closer to the ceiling. I remember in particular one 3rd-party control (a grid) that could display small images, but refused to release their handles until it was destroyed. Many a curse was heard from the direction of QA, as their stress-tests failed spectacularly half-way through with a Win3.1-ish "white screen of lameness". I ended up writing a beautiful hack to draw all the images over the top of the grid once it was done drawing itself - ah, good times... :rolleyes:

                      My god, you're a genius! - Jörgen Sigvardsson, The Lounge

                      J 1 Reply Last reply
                      0
                      • S Shog9 0

                        Better! It was really small in W95 and W98, but the shell itself used more in W98, so you essentially started out closer to the ceiling. I remember in particular one 3rd-party control (a grid) that could display small images, but refused to release their handles until it was destroyed. Many a curse was heard from the direction of QA, as their stress-tests failed spectacularly half-way through with a Win3.1-ish "white screen of lameness". I ended up writing a beautiful hack to draw all the images over the top of the grid once it was done drawing itself - ah, good times... :rolleyes:

                        My god, you're a genius! - Jörgen Sigvardsson, The Lounge

                        J Offline
                        J Offline
                        J Dunlap
                        wrote on last edited by
                        #12

                        Shog9 wrote:

                        It was really small in W95 and W98, but the shell itself used more in W98, so you essentially started out closer to the ceiling.

                        I don't remember Win98 1st Edition being much worse off as far as that, but Win98SE definitely was. You'd restart and then you'd barely do anything before you'd have to restart again.

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          Oh, OK. I didn't recall that, especially, but I believe you :-) Was the limit really small and then grew in W98 ? I did write a paint program for W95, but I developed it using W98 and then 2000. Christian Graus - Microsoft MVP - C++

                          L Offline
                          L Offline
                          Luis Alonso Ramos
                          wrote on last edited by
                          #13

                          Does someone remember GetFreeSystemResources? everyone used it to show a little number in their About box... as if users did care! :laugh: -- LuisR


                          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

                          The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

                          1 Reply Last reply
                          0
                          • C Chris Maunder

                            I mean that you were strictly limited in the number of GDI objects you could create (without releasing) before the system started refusing to grant you more. You quickly learned to check the return values of system calls :) cheers, Chris Maunder

                            CodeProject.com : C++ MVP

                            R Offline
                            R Offline
                            Ravi Bhavnani
                            wrote on last edited by
                            #14

                            Actually it was much worse in Win 3.1 - I spent several sleepless weekends debugging this[^]. :sigh: /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                            N 1 Reply Last reply
                            0
                            • R Ravi Bhavnani

                              Actually it was much worse in Win 3.1 - I spent several sleepless weekends debugging this[^]. :sigh: /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                              N Offline
                              N Offline
                              Neville Franks
                              wrote on last edited by
                              #15

                              Win 2.0 was even worse still.;) Mind you thankfully that is but a faint memory. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

                              1 Reply Last reply
                              0
                              • J Joshua Quick

                                For all of you MFC developers out there busy trying to locate what's causing those recent GDI leaks in your app, take a look at this. It turns out running MFC apps on WinXP sp2 and Win2003 leaks GDI resources while XP themes are enabled. The bug report on Microsoft's site is dated this month, so it looks like a recent issue (otherwise I would have been pulling out hairs months ago). Here is their bug report. http://support.microsoft.com/?id=319740[^] I tell ya, this one was driving me nuts for the past week. Going over thousands of lines of code only to discover later that it's not my bug. So, I thought I'd be a good CP member and share this with the rest of you.

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #16

                                Recent? You must be joking - this issue is at least 12 months old - I first reported it here on CP in September last year. I also successfully got MS to release a patch for this bug, which I view as a personal triumph! I assure you that this problem will have been affecting your MFC apps since XP SP2 was released. Way to go MS! http://www.codeproject.com/lounge.asp?msg=927571&searchkw=mfc+leak&sd=1%2F1%2F2003&ed=10%2F25%2F2005#xx927571xx[^]


                                The Rob Blog
                                Google Talk: robert.caldecott http://www.codeproject.com/script/comments/forums.asp?msg=927057&forumid=2605&searchkw=mfc+leak+hrgn&sd=1%2F1%2F2004&ed=12%2F31%2F2004#xx927057xx[^] -- modified at 3:18 Tuesday 25th October, 2005

                                J 1 Reply Last reply
                                0
                                • C Chris Maunder

                                  Anyone remember the fun and games of Win95's GDI? cheers, Chris Maunder

                                  CodeProject.com : C++ MVP

                                  M Offline
                                  M Offline
                                  Michael Dunn
                                  wrote on last edited by
                                  #17

                                  Yes. I'm glad I have more than 64K to work with these days. ;) --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?

                                  1 Reply Last reply
                                  0
                                  • C Chris Maunder

                                    I mean that you were strictly limited in the number of GDI objects you could create (without releasing) before the system started refusing to grant you more. You quickly learned to check the return values of system calls :) cheers, Chris Maunder

                                    CodeProject.com : C++ MVP

                                    V Offline
                                    V Offline
                                    Vikram A Punathambekar
                                    wrote on last edited by
                                    #18

                                    How dare you post a programming question in the Lou... Oh, it's you, Chris! No, don't mind me... nothing at all... just thought I'd say Hi. ;P Cheers, Vikram.


                                    http://www.geocities.com/vpunathambekar

                                    Google talk: binarybandit

                                    After all is said and done, much is said and little is done.

                                    1 Reply Last reply
                                    0
                                    • L Lost User

                                      Recent? You must be joking - this issue is at least 12 months old - I first reported it here on CP in September last year. I also successfully got MS to release a patch for this bug, which I view as a personal triumph! I assure you that this problem will have been affecting your MFC apps since XP SP2 was released. Way to go MS! http://www.codeproject.com/lounge.asp?msg=927571&searchkw=mfc+leak&sd=1%2F1%2F2003&ed=10%2F25%2F2005#xx927571xx[^]


                                      The Rob Blog
                                      Google Talk: robert.caldecott http://www.codeproject.com/script/comments/forums.asp?msg=927057&forumid=2605&searchkw=mfc+leak+hrgn&sd=1%2F1%2F2004&ed=12%2F31%2F2004#xx927057xx[^] -- modified at 3:18 Tuesday 25th October, 2005

                                      J Offline
                                      J Offline
                                      Joshua Quick
                                      wrote on last edited by
                                      #19

                                      Robert Edward Caldecott wrote:

                                      Recent? You must be joking - this issue is at least 12 months old

                                      :wtf: Crap! If this is true, then... 1) All of my long running MFC apps are in jeopardy. 2) Microsoft is seriously not cool. They should have fixed this via Windows Update a long time ago. 3) I made a repost. D'oh! Interestingly enough, I haven't heard of any my long running MFC apps bombing in the past year. These apps run 24/7/365 and periodically create and destroy MDI child windows. Are you sure MS didn't fix this? Anyways, where can I download this patch? (Don't tell me I have to go through their tech support team, do I?)

                                      L 1 Reply Last reply
                                      0
                                      • J Joshua Quick

                                        Robert Edward Caldecott wrote:

                                        Recent? You must be joking - this issue is at least 12 months old

                                        :wtf: Crap! If this is true, then... 1) All of my long running MFC apps are in jeopardy. 2) Microsoft is seriously not cool. They should have fixed this via Windows Update a long time ago. 3) I made a repost. D'oh! Interestingly enough, I haven't heard of any my long running MFC apps bombing in the past year. These apps run 24/7/365 and periodically create and destroy MDI child windows. Are you sure MS didn't fix this? Anyways, where can I download this patch? (Don't tell me I have to go through their tech support team, do I?)

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #20

                                        They may well of patched this via a Windows Update - there is no way of telling. And yes, I had to go through MS tech support for the hot-fix, so I am not meant to give it to you. :( Oh, and MS support sent me the KB319740 link 12 months ago too. I did find a workaround though - make a call to SetWindowTheme(hWnd, L"", L"") in OnCreate. This means your MDI child windows won't get the XP theme look to their captions, but you'll still get themed controls, etc.


                                        The Rob Blog
                                        Google Talk: robert.caldecott

                                        J G 2 Replies Last reply
                                        0
                                        • L Lost User

                                          They may well of patched this via a Windows Update - there is no way of telling. And yes, I had to go through MS tech support for the hot-fix, so I am not meant to give it to you. :( Oh, and MS support sent me the KB319740 link 12 months ago too. I did find a workaround though - make a call to SetWindowTheme(hWnd, L"", L"") in OnCreate. This means your MDI child windows won't get the XP theme look to their captions, but you'll still get themed controls, etc.


                                          The Rob Blog
                                          Google Talk: robert.caldecott

                                          J Offline
                                          J Offline
                                          Joshua Quick
                                          wrote on last edited by
                                          #21

                                          That's good to know. Thanks for the tip Robert.

                                          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