Thread: Memory leak detection...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Memory leak detection...

    Is there a way detect memory leaks without going through the code and look for them? Some technic, or maybe a developer tool?


    Thank you.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Something I have done is overload new and delete.

    Arrange it such that the new new/delete log where they were called from and what they were asked to do.

    Examine the logs, look for unpaired calls for example.

    Depending on OS, there are other approaches, but that works at the language level.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    so in other words to track on a code level the allocating ?
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  4. #4
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Here is a link to a garbage collection library for C and C++. I'm not sure how well it works though since I've never tried it.

  5. #5
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    i'm not looking to replace the functions but to track them without too much trouble
    There are also API function with handles and objects that should also be closed or freed...
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    You can also wrap API functions in logging wrappers if you need to.

    Memory leaks are usually either bad design work, or poor implementation of a good design. Whenever I have been asked to find a stubborn memory leak, it has almost always been sloppy coding, not anything esoteric or weird.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    Well, i'm talking about slappy coding... because we are all human after all

    Can you please explain alittle more about the logging wrapers, and how do I do it?
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. memory leak checker program? for windows
    By rahulsk1947 in forum C Programming
    Replies: 1
    Last Post: 11-12-2007, 07:20 AM
  3. Memory leak with detached pthreads - how to free?
    By rfk in forum Linux Programming
    Replies: 2
    Last Post: 08-17-2007, 06:50 AM
  4. Huge memory leak
    By durban in forum C++ Programming
    Replies: 3
    Last Post: 11-01-2005, 12:10 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM