• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Memory leaks

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Memory leaks

    I'm working on the client's product which leaks according to Task Manager.

    We allocate huge numbers of buffers (tens of thousands) every second and the product is supposed to run for days. At the moment it leaks about 1/3 MB per minute which is unacceptable.

    It seem to me that anyone with half a brain would have created a pooled memory scheme with various sized buffers, to avoid fragmentation and the overheads of malloc and free.

    Anyway, I've convinced myself that none of the libraries are leaking enough to explain the leak (by logging all mallocs and frees). And I've made sure that all modules use the same version of the CRT.

    After many weeks of getting nowhere I'm running out of hair to tear out I might have to make use of other peoples scalps.

    So to the question: can memory fragmentation have the same symptoms as memory leakage?

    #2
    mallocs and frees...

    ...oh dear, you're still using a legacy language aren't you?

    Joking aside, for this sort of problem in the past I used to find the Numega (or whoever they're owned by, or own, these days) tools very useful. No doubt there are others.

    A quick Google should find them or something similar...perhaps even a 30 day trial...my life-saver on many a project.

    Comment


      #3
      Download yerself a copy of Boundschecker or Purify.

      Comment


        #4
        Have you got task manager showing you GDI objects and handles as well as memory?

        If the memory usage value keeps climbing over time, then it's definitely a leak rather than fragmentation.

        I'm free to try and fix it if you need help.
        Will work inside IR35. Or for food.

        Comment


          #5
          Originally posted by VectraMan
          Have you got task manager showing you GDI objects and handles as well as memory?

          If the memory usage value keeps climbing over time, then it's definitely a leak rather than fragmentation.

          I'm free to try and fix it if you need help.
          It's not GDI objects (no windows/graphics) or handles. Sadly.

          Comment


            #6
            Originally posted by GeorgeGregan
            Download yerself a copy of Boundschecker or Purify.
            I should have pointed out that the codes C and (in the loosest sense of the term) C++ though I guess that was fairly obvious.

            I pursuaded the client to purchase a Purify licence but it runs at least 20x more slowly, and loads of timers go off, screwing the whole shooting match, and the run fails before it has even done anything of interest. It's probably too much hassle to sort it out to work with Purify as we will need to hack/regenerate loads of XML scripts. So basically it's useless. Bounds Checker costs too, and I would assume it also has too much overhead.

            I've tried UMDH which does not work except in snapshot mode and that indicates no leaks. The symbols look fine, gflags was used to enable user stack trace, but no joy with UMDH in non snapshot mode. I have no problem with UDMH on notepad.exe.

            I've used CDB from a console window and that shows one segment in one of the heaps growing with time. Examining the segment contents does not give any clues.

            Comment


              #7
              Originally posted by Joe Black
              ...oh dear, you're still using a legacy language aren't you?

              Joking aside, for this sort of problem in the past I used to find the Numega (or whoever they're owned by, or own, these days) tools very useful. No doubt there are others.

              A quick Google should find them or something similar...perhaps even a 30 day trial...my life-saver on many a project.
              Thanks, but I've used both Purity and Bounds Checker on past projects. But Purify is not up to the task as it has too high a loading. Sigh.

              Comment


                #8
                Bounds Checker tends to make everything crawl too, and if you use MFC it reports lots of leaks that aren't really there.

                If you stop the program just before it finishes shutting down, does the memory usage go back down? There's a difference between a memory leak (i.e. allocated but the pointer to it is lost so never freed), and a program that incorrectly allocates more and more memory. So if it's all freed at the end then that indicates the latter and should give you a clue.
                Will work inside IR35. Or for food.

                Comment


                  #9
                  Originally posted by VectraMan
                  Bounds Checker tends to make everything crawl too, and if you use MFC it reports lots of leaks that aren't really there.

                  If you stop the program just before it finishes shutting down, does the memory usage go back down? There's a difference between a memory leak (i.e. allocated but the pointer to it is lost so never freed), and a program that incorrectly allocates more and more memory. So if it's all freed at the end then that indicates the latter and should give you a clue.
                  Hi VectraMan

                  Yes I've tried to determine if it really is leaking, i.e. losing references, or simply not freeing memory that is no longer used. As far as I can tell it is leaking.

                  Life is so much easier if it's done right (or nearly right) from the start. Oh well, I s'pose that's why muggins is on the case ...

                  Thanks.

                  Fungus

                  Comment


                    #10
                    I'm bored again today so I'm going to provide further evidence of my ignorance.

                    Could this be heap based resources that aren't being released? Nothing to do with the code's mallocs.

                    Spent ages once tracking down a problem that turned out to be a timer not being released. Under normal circumstance the job did what was expected and the timer was destroyed, however when it it timed out, the old timer wasn't being release while a new one was being created.

                    Are all the resources being destroyed?

                    Does your ma like eggs?

                    Comment

                    Working...
                    X