Look back and shudder

I’m currently investigating a memory leak in a complicated piece of multi-threaded code. Unfortunately the code doesn’t have any unit tests and the leak only shows up reliably in the release build. Worse, I wrote the code and nobody has fiddled with it since, so it’s my leak and my code and I have nobody to complain about and no excuses. I miss the unit tests and loose coupling that would be present if I hadn’t written this particular piece of code quite so long ago.

The bug is in the most contrived of the socket server example servers that are freely available on this site. It was written in 2003 and shortly after that release I decided to add tests, refactor and generally clean the whole thing up. The new version of the server doesn’t leak, there are a million and one changes between the new version and the version that I give away, I’m not going to start giving away the latest code and so I have to find and fix the bug in the old version.

Still, at least the old version of the code makes me realise how much I’ve improved things since then… It’s still painful to have to face up to the fact (again) that the design and implementation of that old code was so bad… Still, at least I faced up to it once before and refactored it and added tests so that the code that I write for my clients that is based on this framework is testable and has a better design…