Leakin’ dem bytes
|
Memory leaks are something that programmers (especially those in C and C++) always have to keep in mind. Unfortunately, we didn’t really think about them until roughly halfway into the project. That means we end up with something like this:
Taken from our pre-alpha playtesting build. This could have ended up a lot worse than it actually did. We didn’t really have any constant leaks, so the total leaks didn’t grow in size. Now, for those of you that aren’t that into programming, the ELI5 version of a memory leak is that the program loads things into memory, but doesn’t clear it out. For example, if you create an integer, but don’t clear it out before exiting the program, Visual Leak Detector (or other detectors) would report a 4 byte memory leak. I took it upon myself to clear out all these leaks, which meant going at them one at a time, until no more leaks were reported. Most of the leaks were just cases of forgetting to go through containers (vectors, maps, and so on) and deleting whatever was in it, or running erase instead of deleting, thinking it would clear out the memory (it won’t). There were some odd leaks that I really had trouble wrapping my head around. One of those were in our AI states, where VLD would report a leak from a std::string in the state, which confused me to no end. Turns out that this leak was caused by not having a virtual destructor in our base AI state, which resulted in the string not being deleted. After roughly a week of making sure things get deleted properly, I end up with this:
… aswell as two scolded programmers. >.> So what does it matter if you have memory leaks in your program? There are a couple of reasons as to why leaks are bad:
All in all, memory leaks are bad, and programmers should do their best to avoid getting them. For the programmers in the other groups, for your own sake, include VLD (or something similar) and check for leaks. Do it now. You don’t want to go into the final week(s), find out you have a ton of leaks, and end up not being able to fix them due to lack of time.
|