Why was the ability to specify an allocator during CoInitialize removed from the system?
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.
Comments
Anonymous
February 08, 2007
I was doing some shell32 interop in C# and ran into SHGetMalloc but in the end it was never needed that I use it, all API calls suggested alternatives. My search for what I saw turned up this link and it didn't really surprise me it is to the old new thing. :) http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspxAnonymous
February 08, 2007
The comment has been removedAnonymous
February 08, 2007
Rob, I'm not sure why it wasn't removed - most likely it was as an aid to help in porting apps from Win16 to Win32 - not providing a param is easy - if someone saved a copy of the allocator away and used it offline, it might be harder to port.Anonymous
March 06, 2007
Pretty interesting. I never even though about why that parameter was there.Anonymous
March 07, 2007
The comment has been removed