Yesterday I talked about CoGetMalloc. One thing I didn’t include was why the ability to specify an allocator was removed from the system. If you’ve read Raymond’s blog, the answer should be obvious. I suspected it, but wasn’t sure, but after I submitted yesterday’s post, I got an email internally.
The ability to specify an allocator was a feature added back in the days when applications were trusted not to screw up.
Unfortunately, whenever applications are given the ability to screw up, they did. They provided their own IMalloc implementations, many of which didn’t correctly implement the IMalloc contract. Now this isn’t necessarily a big deal – the application just stomped on itself, right, so it’s the application’s fault, right? Well yeah, but sometimes these 3rd party allocators took out windows components as well. All in all, it wasn’t very pretty.
When the 32bit version COM was implemented (for NT 3.5), the decision was made to deprecate the first parameter to CoInitialize/CoInitializeEx. The IMallocSpy API was added to allow applications the abiity to track leaks and monitor memory. The COM guys were able to get away with this breaking change because all 32 bit applications were new applications, thus no existing applications would be broken by the change.