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 searcher?

Memory leak searcher?

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
9 Posts 7 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.
  • C Offline
    C Offline
    Chun Te Ewe
    wrote on last edited by
    #1

    Dear all, Correct me if I'm wrong, is memory leak due to not using delete after a new? Is there a program to check my program for memory leak? Thanks Chun Te, Ewe

    J S D 3 Replies Last reply
    0
    • C Chun Te Ewe

      Dear all, Correct me if I'm wrong, is memory leak due to not using delete after a new? Is there a program to check my program for memory leak? Thanks Chun Te, Ewe

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      Chun Te, Ewe wrote: Correct me if I'm wrong, is memory leak due to not using delete after a new? Yes. Or using delete instead of delete[] for an array made with new[] Chun Te, Ewe wrote: Is there a program to check my program for memory leak? 'BoundsChecker' or 'Purify' spring to my mind. Both are big money, but very good.

      C B 2 Replies Last reply
      0
      • C Chun Te Ewe

        Dear all, Correct me if I'm wrong, is memory leak due to not using delete after a new? Is there a program to check my program for memory leak? Thanks Chun Te, Ewe

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

        If that's window objects such like GDI handles, this article [^](and tool) may help you.


        MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.

        1 Reply Last reply
        0
        • J jhwurmbach

          Chun Te, Ewe wrote: Correct me if I'm wrong, is memory leak due to not using delete after a new? Yes. Or using delete instead of delete[] for an array made with new[] Chun Te, Ewe wrote: Is there a program to check my program for memory leak? 'BoundsChecker' or 'Purify' spring to my mind. Both are big money, but very good.

          C Offline
          C Offline
          Chun Te Ewe
          wrote on last edited by
          #4

          jhwurmbach wrote: 'BoundsChecker' or 'Purify' spring to my mind. Both are big money, but very good. Are there any freewares around?

          J 1 Reply Last reply
          0
          • C Chun Te Ewe

            Dear all, Correct me if I'm wrong, is memory leak due to not using delete after a new? Is there a program to check my program for memory leak? Thanks Chun Te, Ewe

            D Offline
            D Offline
            dazinith
            wrote on last edited by
            #5

            this is one way to cause a memory leak.. another way is to serialize an object array which creates the objects using the word new, and does this everytime the file is loaded.. before serializing an object array you should delete everything in it before loading the objects into it again.. these are a few ways to have memory leaks. -dz

            1 Reply Last reply
            0
            • C Chun Te Ewe

              jhwurmbach wrote: 'BoundsChecker' or 'Purify' spring to my mind. Both are big money, but very good. Are there any freewares around?

              J Offline
              J Offline
              Jawache
              wrote on last edited by
              #6

              Not really.... the tools available are really for checking whether you are going past array bounds or accessing memory that hasn't been allocated. VC++ tells you when you have a memory leak and thats about as much help as your going to get anywhere. There are a number of good articles here about how to trace your memory leaks better, look in 'Programming Tips' Asim Hussain e: asim@jawache.net w: www.jawache.net

              1 Reply Last reply
              0
              • J jhwurmbach

                Chun Te, Ewe wrote: Correct me if I'm wrong, is memory leak due to not using delete after a new? Yes. Or using delete instead of delete[] for an array made with new[] Chun Te, Ewe wrote: Is there a program to check my program for memory leak? 'BoundsChecker' or 'Purify' spring to my mind. Both are big money, but very good.

                B Offline
                B Offline
                Bart Robeyns
                wrote on last edited by
                #7

                Just being obnoxious: if I'm not mistaking the 'delete[]'-syntax is no longer needed when trying to delete an array. Following code does exactly the same thing twice: void main() { char* s = new char[10]; delete s; char* p = new char[10]; delete []p; }

                R 1 Reply Last reply
                0
                • B Bart Robeyns

                  Just being obnoxious: if I'm not mistaking the 'delete[]'-syntax is no longer needed when trying to delete an array. Following code does exactly the same thing twice: void main() { char* s = new char[10]; delete s; char* p = new char[10]; delete []p; }

                  R Offline
                  R Offline
                  RChin
                  wrote on last edited by
                  #8

                  Have a look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_Using_delete.asp The following two cases produce undefined results: using the array form of delete (delete [ ]) on an object and using the nonarray form of delete on an array.

                  B 1 Reply Last reply
                  0
                  • R RChin

                    Have a look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_Using_delete.asp The following two cases produce undefined results: using the array form of delete (delete [ ]) on an object and using the nonarray form of delete on an array.

                    B Offline
                    B Offline
                    Bart Robeyns
                    wrote on last edited by
                    #9

                    I stand completely corrected. I was confused with the change from 'delete [n] array' to 'delete [] array'. And I was lucky in the example I gave, because the difference between 'delete [] array' and 'delete array' is that in the latter case no destructors are called while in the former they are. But in my example I was silly enough to use char's, who, obviously, have no destructors at all.

                    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