Note: This post will only be of interest to other software developers. Feel free to skip it if you're not a programmer :)
After a large corporate customer of ours upgraded to the latest version of FeedDemon, they complained that the "Subscription Home" report took a much longer time to display than it did in the previous version.
At first I was stumped by this, since nobody else had mentioned similar problems. But then I discovered that they were subscribed to several thousand feeds - far more than most FeedDemon customers. Most of these feeds had unread items, which meant that the subscription report was displaying pretty much every feed they were subscribed to.
After I got a copy of their feeds, I saw the problem right away: it turned out to be caused by the favicons that were added to this report in the latest version. The way I had coded it, the string which held the contents of the report was being reallocated every single time a favicon was inserted into it. So with this customer's subscriptions, the report string was being reallocated several thousand times. Ouch.
High-level programming languages usually handle memory allocation behind-the-scenes, so you're often unaware that it's happening, but I should've known better. Many years ago I programmed in assembler, so I know what's really going on when dealing with string operations. Memory allocation is a big reason why many string operations are slow, and when you insert one string into another, the memory for the destination string has to be reallocated to allow enough room for the inserted characters.
Anyway, after chiding myself for my newbie mistake, I rewrote the code so that all memory was pre-allocated up front, and the favicons were simply copied directly into this pre-allocated memory (in other words, inserting favicons into the report string now requires a single memory allocation). The code is significantly more complex than it was, but my profiler shows that it's now 1137.81% faster than before.
That strikes me as a pretty good illustration of the performance cost of memory allocation :)