Sunday, September 12, 2004

More memory leaks

Toward the end of 1996 I was seconded to a team of developers writing a database management system. The project was to run on Windows NT 4, was written in C++ and used an object oriented database (remember those?). Anyway, the majority of the other developers (all 5 of em) had a strong UNIX/C++ background whilst I had a strong Windows background, which is why I was seconded.

The database leaked memory like a sieve. I'm not kidding when I say that after running a single query and terminating the program the debugger took between 15 and 20 minutes to print out all the memory leaks. Most of the developers simply pressed the 'Stop' button on the debugger to terminate the program immediately rather than let the memory allocator print out it's diagnostics.

I asked them why they didn't fix the leaks. The first answer was that it wasn't their code, it was Windows! If it had been running on UNIX the operating system would handle it so it was obviously Windows fault. Hmm, I never did manage to convince em they were wrong on that one. The second answer was that they were only small leaks, only a few bytes per leak and any decent VM system should be able to handle that. Yes, they were only small leaks, millions of the buggers!

We had the source code to the database but it was 'too hard' to go in and fix the leaks. Now remember, this is 1996 when 128 Megs of memory in your machine put you into the power user category, and NT took about 90 of those megs. With nothing else but our app running it took about 25 queries to leak enough memory that swapping kicked in.

Their solution? They wrapped all the database code into a seperate executable and launched it for every single query. That way the database could leak all the memory it wanted; Windows would clean up after it. Of course, performance suffered but we developers were running on the latest and greatest Pentium systems so it wouldn't hurt us! Only the poor customer who still nursed hopes of getting reasonable performance on a 66 MHz 486. (I hope the sarcasm is coming through).

Mercifully the project was canned after a month or so and the other developers were free to pursue other contracts whilst I returned to normal duties. Oh, and the lead programmer on the team? It turns out he had the Australian dealership for the object database involved. What a surprise!

No comments: