Thread: memory leaks

  1. #1
    Registered User
    Join Date
    Nov 2002

    memory leaks

    what are they?

  2. #2
    Registered User
    Join Date
    Sep 2002
    Unnessecary variable that keep taking more and more memory.
    [/not really proffesional mode]

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    It's usually when you allocate heap memory (say with malloc, new or a system call) and then either neglect to free it, or lose the option to free it

    int* lpint = new int;//allocate an int on the heap

    *lpint = 5;//assign value

    lpint = new int;//now allocate another int

    *lpint = 10;//assign value

    delete lpint;

    This frees the memory with the value 10 in it...the one with 5 in it is leaked and cannot be freed..also allocating memory in a function and returning before freeing - assuming the pointer is not accessible from another part of the code.........other more complex situations like throwing an exception in C++ before allowing resources to be freed........etc...etc

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking for memory leaks
    By Bladactania in forum C Programming
    Replies: 5
    Last Post: 02-10-2009, 12:58 PM
  2. memory leaks
    By TehOne in forum C Programming
    Replies: 4
    Last Post: 10-10-2008, 09:33 PM
  3. Tons of memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 12-05-2005, 10:19 AM
  4. COM Memory Leaks
    By subdene in forum Windows Programming
    Replies: 0
    Last Post: 06-07-2004, 11:57 AM
  5. about memory leaks with this simple program
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 04-07-2002, 07:19 PM