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. C / C++ / MFC
  4. Memory Leak detection

Memory Leak detection

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
15 Posts 8 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.
  • D David Crow

    Shay Harel wrote:

    What if I am running someone else's code and I want to check for memory leaks, is that doable ?

    While it may be possible to detect if it has or hasn't, you'd have no way of determining where.


    "Take only what you need and leave the land as you found it." - Native American Proverb

    S Offline
    S Offline
    Shay Harel
    wrote on last edited by
    #3

    I'll go with the first option. If I can prove an application is leaking memory, I can get the developer to fix it. All I need to do is to prove it does it.

    T 1 Reply Last reply
    0
    • S Shay Harel

      I'll go with the first option. If I can prove an application is leaking memory, I can get the developer to fix it. All I need to do is to prove it does it.

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #4

      it looks like a chief behavior, who don't bother at all the guys of his team :( even if you find some memory leaks, how will the developper find the lack ? did you ever coded in your life dude ?! :suss:


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      S 1 Reply Last reply
      0
      • T toxcct

        it looks like a chief behavior, who don't bother at all the guys of his team :( even if you find some memory leaks, how will the developper find the lack ? did you ever coded in your life dude ?! :suss:


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        S Offline
        S Offline
        Shay Harel
        wrote on last edited by
        #5

        To start with, I wrote tons of code and still does. However, I am using someone else's application and I need to prove it's causing memory leaks. Since this application runs for days, the leaks are finally halting the system. The problem is we have multiple applications running on the background and we need to find the culprit. Sounds better ?

        T 1 Reply Last reply
        0
        • S Shay Harel

          To start with, I wrote tons of code and still does. However, I am using someone else's application and I need to prove it's causing memory leaks. Since this application runs for days, the leaks are finally halting the system. The problem is we have multiple applications running on the background and we need to find the culprit. Sounds better ?

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #6

          Shay Harel wrote:

          Sounds better ?

          few... as the program is not running alone on its machine, there could be leaks at several places.


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          S 1 Reply Last reply
          0
          • T toxcct

            Shay Harel wrote:

            Sounds better ?

            few... as the program is not running alone on its machine, there could be leaks at several places.


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            S Offline
            S Offline
            Shay Harel
            wrote on last edited by
            #7

            Which was my original question... Is there any application out there that somehow monitors memory usage per application so I can see if any of the applications just consume more and more memory.

            R 1 Reply Last reply
            0
            • S Shay Harel

              Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay

              B Offline
              B Offline
              Blake Miller
              wrote on last edited by
              #8

              Configure the application for 'constant' behavior. That is some well-defined repeatable behavior that should USE memory but not LEAK memory. Set up performance monitor to watch this application's working set size and private bytes. Chart over a day or two, or until application halts. Then see if that application has a constantly growing use of the working set size and private bytes. You can probably assume it has a memory leak.

              S 1 Reply Last reply
              0
              • B Blake Miller

                Configure the application for 'constant' behavior. That is some well-defined repeatable behavior that should USE memory but not LEAK memory. Set up performance monitor to watch this application's working set size and private bytes. Chart over a day or two, or until application halts. Then see if that application has a constantly growing use of the working set size and private bytes. You can probably assume it has a memory leak.

                S Offline
                S Offline
                Shay Harel
                wrote on last edited by
                #9

                I will try that

                1 Reply Last reply
                0
                • S Shay Harel

                  Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay

                  V Offline
                  V Offline
                  vgrigor1
                  wrote on last edited by
                  #10

                  To find memory leaks using just Visual stidio,- is unappropriate complex task. visual studio does only small chek and nothing more, so slightly complex errors remains hardly found. Best and easy way to use specialized program like BoundsChecker, or something like this.

                  1 Reply Last reply
                  0
                  • S Shay Harel

                    Which was my original question... Is there any application out there that somehow monitors memory usage per application so I can see if any of the applications just consume more and more memory.

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

                    MemWatcher[^] may help to verify memory degradation. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                    1 Reply Last reply
                    0
                    • S Shay Harel

                      Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay

                      L Offline
                      L Offline
                      LighthouseJ
                      wrote on last edited by
                      #12

                      I like to drop in MMGR. Add it to your project, then read the comments in mmgr.cpp to use it. It will record every allocation without adding the header file to your project files, but it won't record the file and line number of the allocation unless the mmgr.h is included. It can record every memory allocation or only mem leaks in a text file that's easy to read. It helped me spot places where I allocated an array of characters, eg. I used

                      delete item;

                      on an array called item instead of

                      delete[] item;

                      and things like that. There are plenty of asserts in there with comments that tell you what you did wrong to cause the assertion.

                      J 1 Reply Last reply
                      0
                      • L LighthouseJ

                        I like to drop in MMGR. Add it to your project, then read the comments in mmgr.cpp to use it. It will record every allocation without adding the header file to your project files, but it won't record the file and line number of the allocation unless the mmgr.h is included. It can record every memory allocation or only mem leaks in a text file that's easy to read. It helped me spot places where I allocated an array of characters, eg. I used

                        delete item;

                        on an array called item instead of

                        delete[] item;

                        and things like that. There are plenty of asserts in there with comments that tell you what you did wrong to cause the assertion.

                        J Offline
                        J Offline
                        James R Twine
                        wrote on last edited by
                        #13

                        FWIW, I do not think that kind of error causes a memory leak directly (only indirectly).  Missing the [] operator causes only the first object in the array to have its destructor called, but the memory block itself is still freed.    For example, if you missed the brackets on an array of simple types, there should be no memory leaks.  However, if the array was an array of complex objects that themselves allocate memory, then that might indirectly cause leaks because the destructors will not be called on objects 2-n in the array.    Peace! -=- James


                        If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                        Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                        DeleteFXPFiles & CheckFavorites (Please rate this post!)

                        1 Reply Last reply
                        0
                        • S Shay Harel

                          Hi, As far as I remember, all the articles I have seen for detecting memory leaks were associated with adding some code to your program. What if I am running someone else's code and I want to check for memory leaks, is that doable ? Thanks, Shay

                          J Offline
                          J Offline
                          James R Twine
                          wrote on last edited by
                          #14

                          This may be a dumb question, but why can you not just use Task Manager, and look at the memory consumption of the process in question?    Over time, if leaks do exist, you should be able to see an increase in total memory usage over time.    Peace! -=- James


                          If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                          Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                          DeleteFXPFiles & CheckFavorites (Please rate this post!)

                          S 1 Reply Last reply
                          0
                          • J James R Twine

                            This may be a dumb question, but why can you not just use Task Manager, and look at the memory consumption of the process in question?    Over time, if leaks do exist, you should be able to see an increase in total memory usage over time.    Peace! -=- James


                            If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                            Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                            DeleteFXPFiles & CheckFavorites (Please rate this post!)

                            S Offline
                            S Offline
                            Shay Harel
                            wrote on last edited by
                            #15

                            yes, this is a "memory leak" 101 thing. I was looking for something that will do that for me and have some reporting instead of me having to look at it all the time.

                            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