I'm not as judgmental about programs with memory leaks now

Discussion in 'OT Technology' started by Limp_Brisket, May 29, 2009.

  1. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    at least if they're written in C++. i'm taking my advanced C++ class right now and as we go he's teaching us all the ways that memory leaks can be introduced into your code, you really have to have an in-depth knowledge of what you're doing in order to make sure that your C++ code isn't introducing memory leaks :mamoru:
     
  2. critter783

    critter783 OT Supporter

    Joined:
    Jul 15, 2005
    Messages:
    1,785
    Likes Received:
    0
    Shit's a bitch, ain't it? You get balls-deep in a problem, and you're trying to focus on the logic flow, and you end up wrestling memory management.
     
  3. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    this is true, but as my C++ teacher constantly stresses C++ is all about only adding additional overhead when you want it, and a garbage collector is a lot of additional overhead.
     
  4. Swerve

    Swerve OT Supporter

    Joined:
    Feb 20, 2005
    Messages:
    3,179
    Likes Received:
    3
    Java's self executing garbage collector can even take a second to run if there's a lot of stuff to clean up, not so good for real time systems.
     
  5. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    That's where encapsulation comes in. If all your dynamic memory allocation is handled by separate code that you interface with (whether it be STL or a framework or even just a class you wrote yourself), then once you've gotten the dynamic allocation working right, you never have to worry about it again.

    I remember how happy I was when I finally wrote an XML tree class for one of my VB6 projects -- once I got it working, I fed it a one-million-element XML file 100 times, assembling and disassembling the tree the slow way instead of hoping VB6 would deallocate the memory for me, and it never hiccupped once.
     

Share This Page