Debugging without breakpoints
Hey all, I know it's been awhile since I've done a dev journal, so I thought that I'd take the time to do one while I'm compiling. Some of the bigger changes that I made for Beta 4 were to improve performance. I spent some time with BoundsChecker tracking down memory leaks. The nice thing about fixing memory leaks is that often fixing one will fix others, and fixing memory leaks fixes problems that they cause. For example, a lot of the memory leaks were in the graphics code. When you leak textures and other graphical resources, you start filling up video memory and that can blow out the video memory. I got a lot of the memory leaks, but I'll have to run BoundsChecker more when I get a chance. The bad thing about debugging with a program like BoundsChecker is that it really slows down the game so it makes testing other things more difficult, so you can't just always run with BoundsChecker turned on.
BoundsChecker, at least, makes it a lot easier to find memory leaks. One of the other things that I had to do for Beta 4 was find out why there was lag on screens like the Ship Design screen and the Planet window. It was a lot more obvious in debug than it was in release, but it was something that needed to be fixed. This problem has been around for awhile, and I had done some cursory testing awhile back so I knew that it had something to do with the mouse messages. I had to go into the code that handled mouse messages and try to figure out what was going on by reading the code and putting in debug messages. Eventually, I figured out that there were a bunch of strange messages being sent to GC2's message loop and that were being passed on to the default message handling code. I couldn't figure out where the spam was coming from, but they were definitely not in the range of our custom application messages. So I put in a check in the message handling code so that it would only process messages within the range of messages that GC2 needs, and I let the rest go to the default Windows message handling function. Sure enough, as soon as I ran GC2 again with my changes, the lag was gone and my framerate had even gone up.
Bugs involving memory and messages and other things that affect performance can be annoying to track down, but fixing them sure gives you a feeling of accomplishment.