Thread: memory leaks

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    72

    [SOLVED]memory leaks

    thanks for your help and sorry for the duplicate topic.

    Regards.
    Last edited by evariste; 02-07-2010 at 01:05 PM.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Well, there isnt really anything special about fixing memory leaks, especially when you can use a tool to verify if they are still present or not to make sure you get them all. Its just a mechanical process. Algorithm:

    For every variable "foo" that you use "malloc" (or similar functions) on, simply look for the last (or second last, if some people are picky) place that that variable is referenced. Of those last 1 or 2 lines, it should contain "free(foo);".
    Of course "last" here doesnt mean "last/bottom in the file", it means last place it will be referenced during execution of the program.

    Aside, I see a number of places in the code where your using "malloc" when theres absolutely no need for it. This just makes things more confusing, and even less efficient for your program. Use it only when you need to!

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Thanks for the answer, i will check again and let you know.

    Many regards.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Yeah, see my answers over on devshed.com

    How To Ask Questions The Smart Way
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Yes and i reply to you on the same forum and i'm waiting for your suggestions.

    Thanks.

  6. #6
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    you are in the 2 forums, so they are necessary both a good forums, and i have reason to post my question on both .

    Regards.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by evariste
    you are in the 2 forums, so they are necessary both a good forums, and i have reason to post my question on both
    Sure, but only after you fail to receive any satisfactory replies from one of them.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    We have the choice to post our questions in the forum of our choice until we get a satisfied answer to our question! i don't know there is a problem!!! you can help me to answer my question and you can choose to not do. The world is open.

    Regards.

  9. #9
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    if there is a polemic about my topic, i will close it. Thank you for your time spending to answer the questions of others.

    Regards.

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by evariste
    We have the choice to post our questions in the forum of our choice until we get a satisfied answer to our question! i don't know there is a problem!!! you can help me to answer my question and you can choose to not do. The world is open.
    There is the matter of ettiquette. Consider this from the point of view of people helping you: people may take the time to help you, only to find out that their efforts were wasted because you already were given pretty much the same help.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Thanks, topic is close.

    Regards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Valgrind memory leaks - Dakar or real?
    By DaleCooper in forum C Programming
    Replies: 6
    Last Post: 10-14-2009, 04:40 AM
  2. Plugging memory leaks
    By mrsirpoopsalot in forum C++ Programming
    Replies: 4
    Last Post: 10-09-2009, 10:31 PM
  3. Checking for memory leaks
    By Bladactania in forum C Programming
    Replies: 5
    Last Post: 02-10-2009, 12:58 PM
  4. memory leaks
    By TehOne in forum C Programming
    Replies: 4
    Last Post: 10-10-2008, 09:33 PM
  5. COM Memory Leaks
    By subdene in forum Windows Programming
    Replies: 0
    Last Post: 06-07-2004, 11:57 AM