We kept noticing that the computer would begin to bog down after extended periods of driving. This problem was pernicious because it only showed up after 40 minutes to an hour of driving around and collecting obstacles. The computer performance would just gradually slow down until the car just simply stopped responding, usually with the gas pedal down, and would just drive off into the bush until we pulled the plug. We looked through the code on paper, literally line by line, and just couldn't for the life of us imagine what the problem was. It couldn't be the list of obstacles: right there was the line where the old obstacles got deleted. Sitting in a McDonald's the night before the competition, we still didn't know why the computer kept dying a slow death. Because we didn't know why this problem kept appearing at 40 minutes, we decided to set a timer. After 40 minutes, we would stop the car and reboot the computer to restore the performance.
We had vacations coming up a few weeks after the race, so we left the cars in Vegas and returned, two weeks later, to investigate the problem. One of our team members downloaded the 14-day trial of ANTS Profiler and we ran it on our car's guidance code. We profiled the memory usage and saw the obstacle list blowing up. How could this be? We called "delete" on those old obstacles! To our amazement, it was only minutes before we realized that our list of detected obstacles was never getting garbage collected. Though we thought we had cleared all references to old entries in the list, because the objects were still registered as subscribers to an event, they were never getting deleted.http://www.codeproject.com/showcase/IfOnlyWedUsedANTSProfiler.asp
As software engineers, we have a hard time with this concept, but it's worth repeating it again:
IN SOFTWARE, THERE ARE NO SILVER BULLETS
. PROGRAMMING IS FUNDAMENTALLY HARD
This we were told by Fred Brooks 30 years ago,
and yet today most of us still don't truly "get it."
I like GC. I think it's a good idea. But do I think it will instantly remove and nullify all the inherent complexity in programming tasks? Not a chance. Software just isn't that easy.( Collapse )