Thread: Memory leak prevention methodogies

  1. #16
    Join Date
    Oct 2007
    Inside my computer
    Quote Originally Posted by Bubba View Post
    Sorry but that is not my methodology or line of thinking about the design of my code. I know how to properly use memory and understand intimately the lifetime of my objects. Therefore whether I use heap objects or stack objects is purely a moot point. Every C++ programmer should understand how to use the heap. If you understand the heap and understand how to properly use it, I see no issues.

    I do not follow a general rule of AVOID heap objects. Everything is a tool and I just use the right tool at the right time for the right task.
    Sure, you can use heap objects whenever you want, but you can't escape from the fact that when you do, you'll also be introducing potential bugs in your code, beucase those objects must be freed, whether you like it or not.
    So in essence, if you avoid heap objects, you don't need to free. Simple as that.
    It's a good way to avoid leaks, but it's up to everyone to or not to follow the rule.

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    I think Bubba means that he finds an explicit rule about avoiding heap objects superfluous, because he formulates the same rule in a positive way: use the right tool for the right job.

    But having seen what some Java programmers do when they learn C++, I'm not sure I can agree with that. Habits can be hard to get rid of.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Yeah well to each their own. And brewbuck.........what?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory leak in this case?
    By George2 in forum C++ Programming
    Replies: 3
    Last Post: 03-22-2008, 05:05 AM
  2. memory leak in the code?
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 01-13-2008, 06:50 AM
  3. Is this code memory leak free? ---> POSIX Threads
    By avalanche333 in forum C++ Programming
    Replies: 9
    Last Post: 04-13-2007, 03:19 PM
  4. Any Memory Leak Checking Tool?
    By George2 in forum C Programming
    Replies: 4
    Last Post: 06-21-2006, 11:02 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM