memory leaks

This is a discussion on memory leaks within the Tech Board forums, part of the Community Boards category; what are they?...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    46

    memory leaks

    what are they?
    mooooo@cooowwww.com

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    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
    Posts
    5,789
    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 ....ie

    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, 10: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, 12:57 PM
  5. about memory leaks with this simple program
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 04-07-2002, 08:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21