I have been working on an automated way of deploying BizTalk assemblies, orchestrations and bindings without having to use NAnt or MSBuild this week. It has thrown up a problem that lots of people must have if they are doing a similar thing.
Many times, my scripts would fail periodically, but not in predictable places. After looking at the logs I generate, I noticed that there were a lot of “out of memory” errors caused by WMI operations. I needed a quick fix, so I came up with this (horrible and hacky) workaround.
Before each section of code, restart the “winmgmt” service. That’s it. The scripts now work flawlessly – or at least, they fail in predictable places now.
I have just been pointed towards this page which details how to increase the amount of memory available to WMI from its default of 128MB.