I ran into an interesting problem at work. I found the solution the first place I looked, but was terribly surprised to see it there.
How about an explanation.
The problem is called a "memory leak." The idea is that a computer program tells the operating system that it requires a chunk of RAM for something; but when its done, it never tells the operating system to take the RAM back. This leads to a situation where, over time, the program continually asks for more and more memory from the OS, and never gives it back. Eventually the resources are exhausted and the system crashes.
It seemed as though one of the programs I had written was exhibiting this very behavior. Over time, the program's memory usage would slowly climb. And though it would take weeks of uninterrupted use before any definate pattern emerged, the symptoms were clear.
Now, as easy as it is to explain the problem, finding it is a different story. If it were a simple programming error, it could be easily isolated. But in this case, the basic operating logic is slightly different than expected. That is to say, while the program is behaving as expected, the environment in which it runs is different than previously thought; and factors that would otherwise have been harmless are causing the program to behave inapropriately.
So then, how do you isolate this sort of situation? How do you know which one of the thousands of assumptions you made is the one that isn't holding true? There a technique called "profiling" that give you the data you need to make that determination. It involves keeping track of every time you allocate and deallocate every piece of memory you use. You keep track of which programming instruction asked for it, and when you said you're done with it. In theory, over time the offending instruction will have asked for a disproportionate amount of the memory currently in use, and you can then see why that particular piece isn't being given back. It's a nifty idea, but it sure sounds like a lot of work.
That's where profiling tools come in. These are tools that are designed to help you keep track of all this information, and more importantly, interpret the results. It's a pretty tough tool to make, and options are in short supply. This sounds like a job for Google.
While I fully expected a Google search to direct me to a solution, I never thought the solution would be provided by Google itself. You heard that right. Google has a profiling tool. That much doesn't come as a major surprise--they have plenty of reason to analyze the efficiency of the programs they write. But Google also recently made these tools available for the public. For free.
There's a website: http://code.google.com, where Google gives away some of the code that they created as a gift to the software community. Most everything there is only of interest to programmers like me, but that's not the point. The point is that they're doing things for the right reason. They continue to use their resources to make life a little easier for the rest of us, and they ask nothing in return. They've made no attempt to capitalize on most of their creations. What they do get, however, is first prize in the industry's popularity contest. It's a bold strategy. So far, the system has served them well.
Contrast that with the business practices of other companies in the computer field. When the Internet was a new and exciting technology, Microsoft's Bill Gates made the following remark: "I don't care what the Information Superhighway looks like as long as I have a tollbooth on it." It's no secret that the majority of the civilized world distrusts Gates and the company he founded. We know Microsoft just wants our money. And the business practices they've used to get it have been found to be illegal in courts across the world. When Google went public, Gates lamented the universally positive press in an interview, saying "You're not allowed to criticize and say that Google isn't solving all the world's problems." Google is, indeed, one on the most trusted and respected companies in the industry. Even the news media finds difficulty in coming up with something bad to say.
On the one side you have the most wealthy software company in the world and on the other, the most popular. The philosphies of the two couldn't be any more different. One faces disappearing market share, fines, and legal battles over illegal business practices. The other has seen its stock price more than triple in the past few months.