The same happens with PowerShell consoles because of leaked GDI objects

Nov 7, 2011 14:52 GMT  ·  By

It might be less of a good idea to repeatedly open and close a command prompt or a PowerShell console in Windows 7, than you might think, at least according to Microsoft.

The Redmond company reveals that launching and exiting either a command prompt or a PowerShell console multiple times can generate potential problems, and even crash the operating system.

Windows Server 2008 R2 is also affected by this issue, as are the versions of the two platforms that have already been upgraded to Service Pack 1 (SP1).

If customers indeed go ahead and perform the actions described above, Microsoft warns that “the performance of the computer may become slow, and applications may crash.”

Still, the problem is not generalized, as it “occurs when you use a non-English input method (such as the Japanese IME),” Microsoft added.

Apparently, at fault for the poor performance and for the potential crashes are Graphics Device Interface (GDI) objects, which get leaked for every open / close action.

“The leak occurs in the Taskhost.exe process or the Explorer.exe process, depending on whether the language bar is displayed or not. When the number of leaked GDI object handles in the process reaches the maximum number, no more GDI objects can be created,” Microsoft explains.

“When an application receives the focus for the first time, a notification is sent to all language bars. Then, the language bars allocate GDI objects for the application. However, when a command prompt or a PowerShell console is closed, the Conhost.exe process does not send a notification to clean up the GDI objects that were allocated by the language bars. Therefore, the leak occurs.”

Microsoft details the issue in KB2617157, and this article is also the best place for customers to find and download a fix.

The hotfix is available directly from Microsoft support, but users should only deploy it if they are indeed impacted by the glitch described above. Otherwise, they should wait for Windows 7 SP2, which apparently will also pack this hotfix.

Windows 7 SP1 RTM and Windows Server 2008 R2 SP1 RTM are available for download here.