WinForms issue with Windows 10, version 1803

02 August 2018

One of our customers has reported to us a issue with our WinForms controls, one that is related to a GDI resource leak. In their case, it caused an application crash – their system has a limit on how many GDI objects can be allocated.

Upon investigation by the team it turns out that the leak is related to Windows 10 version 1803 (also known as the Windows 10 April 2018 Update), or later.

We devised a really simple test to reproduce the issue:

private void button1_Click(object sender, EventArgs e) {
  for(int x = 0; x < 100; x++) {
    using(var f = new Form() { ShowInTaskbar = false }) {

This particular nasty piece of code – I don’t advise you use it in production! – will “leak” 300 GDI objects, since each form created with ShowInTaskbar = false will leak 3 GDI objects. It’s a very common scenario to have such an option turned on (all popups, tooltips, menus, drag-n-drops, alerts, etc. are examples of such forms), and if the application has a relatively complex UI and is run continuously, sooner or later it will crash or freeze.

We have already devised a workaround for this issue. Needless to say, some rigorous testing is currently being done to make sure we don’t break anything else. We shall be updating our WinForms components from v17.1 or later to include it.

We are contacting Microsoft to see if they aware of the issue, and trying to determine if they have any timeframe for a proper fix.


UPDATE (3-Aug-2018)

It seems I could have been a little more forthcoming and descriptive in my original post, so let me expand a little more. I will also stress that this issue is not specific to DevExpress, but is an “artifact” of the .NET Framework.

Basically the only applications that are really affected are those which use a dynamic UI – that is, apps that create and destroy new forms rather than reuse them (so for example, an invoice/order form where when you create the data entry UI every time the user wishes to enter a new record) – or an app which creates, say, lot of visual notifications.

Since it affects all forms which have ShowInTaskbar = false,  it does apply to almost every one of our UI controls – but I hasten to add that this setting is common practice, and not something we invented here at DevExpress.

Every “dropdown” window is created on the fly in a similar fashion. Examples include: combobox edits, popup menus, lookup edits, backstage menu, filter popups, alert windows, tooltips, drag & drop features, and so on. When you use such editors/controls in a form, a GDI object leak will occur. Now, as it happens, we coded things in such a way to reuse most of these window objects, so if you open the same popup 10 times, say, a leak will occur only once. But if you created a form that contains a combobox 10 times and each time that form is used the user opens the combobox, the app will have leaked 30 GDI handles.

I’d have to say though, since Windows 10 does have a relatively high GDI object limit, the average app would need to be running continuously for a pretty long time before it suffers from a lack of GDI resources.

You can monitor GDI object usage for your apps yourselves: open the Windows Task Manager, go to the Details pane, right-click on the column header row, and choose Select columns. One of the columns is called GDI objects. Select that check box and click OK.

Task Manager GDI object count

Start up your app and watch that new column as you use the UI, especially those forms with examples of those “dropdown” controls I mentioned.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.