GDI Leaks Detection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jurnero
    New Member
    • Aug 2012
    • 32

    GDI Leaks Detection

    Hello! Several times I had a problem with GDI-objects leak.
    My colleagues helped me solve the problem. But I would like to ask for help! How are you searching this type of leak? What utilities or plugins for VS can help me?

    Programming language: C++. Visual Studio
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Are you using C or C++ ?

    You use managed pointers aka smart pointers.

    It's harder n C since you need to set up your own reference counters.

    Then you create these objects using a function that increments the reference count.

    You delete using a function that decrements the reference count and deletes the object if the count is zero.

    In C++ it is handled using managed pointer objects which contain a reference to the object being managed.

    In today's world you should never be using naked pointers anywhere.

    Comment

    • Jurnero
      New Member
      • Aug 2012
      • 32

      #3
      Thanks for the answer.
      Added details to the question
      Programming language is C++/Visual Studio

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        In this case study up on std::shared_ptr <> and its associates.

        Be sure your GDI object ctor/dtor work correctly.

        Depending upon whose GDI object you are using,like one written in C, you may need to embed the object in class object so there is ctor/dtor available.
        Last edited by weaknessforcats; Nov 15 '18, 09:05 PM. Reason: Typos

        Comment

        • Jurnero
          New Member
          • Aug 2012
          • 32

          #5
          Thank you for this clarification. I think it should be very helpful to me.

          Comment

          • JulsSmile
            New Member
            • May 2012
            • 25

            #6
            Maybe you need to spend more time studying the theory. Try reading several articles about the memory model in C ++. This will help you understand how memory is allocated.
            Also, you can use GDI leak detection tools.

            Comment

            • Jurnero
              New Member
              • Aug 2012
              • 32

              #7
              Perhaps you `re right. What books, articles do you recommend to reading? What tools do you mean?

              Comment

              • OldStory
                New Member
                • Aug 2012
                • 23

                #8
                I can advise such debugger as Deleaker. It works with GDI leaks.
                Task Manager can show the presence of such leaks.

                Comment

                • Jurnero
                  New Member
                  • Aug 2012
                  • 32

                  #9
                  OldStory, thanks for the answer. I've heard good reviews about this debugger.

                  Comment

                  Working...