Hello,
Following complaints from our users, we ascertained that our application is 'leaking' GDI handles on more than one Form.
We have built our application using XtraForms to enable us to have 'look and feel'.
Using one of the simpler Forms as an example, and removing all non-DX components (and related code)
we ascertained that the GDI handle count increases by over 20 when this Form is loaded,
but doesn't reduce accordingly when the Form is closed. The only line of code to run is "InitializeComponent();".
No other user-action was performed whilst the Form was displayed.
The components on the Form are as follows:
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchContacts;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchResources;
private DevExpress.XtraBars.Ribbon.RibbonPage ribbonPageSearch;
private DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroupActions;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchSales;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchCasesMain;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchTasks;
private DevExpress.XtraEditors.GroupControl groupControlTitle;
private DevExpress.XtraEditors.LabelControl labelControlTitle;
private DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeel1;
private DevExpress.XtraBars.PopupMenu popupMenuResources;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchStaff;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchOffices;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchAssets;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchSuppliers;
private DevExpress.XtraBars.PopupMenu popupMenuSales;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchEnquiries;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchSubmissions;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchCases2;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchProposals;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchInvoicing;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchFeedback;
private DevExpress.XtraBars.PopupMenu popupMenuCases;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchItems;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchItemProcessing;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchItemObjects;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchExtraMaterials;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchCases;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchMainMenu;
private DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroupMenu;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchExport;
private DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroupExport;
private System.ComponentModel.BackgroundWorker backgroundWorkerSearch;
private DevExpress.XtraLayout.LayoutControl layoutControlSearchFields;
private DevExpress.XtraEditors.XtraScrollableControl xtraScrollableControlMainContent;
private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroupSearch;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
private DevExpress.XtraEditors.SplitContainerControl splitContainerControlSearchResults;
private DevExpress.XtraEditors.PanelControl panelRightControl;
private DevExpress.XtraEditors.LabelControl labelControlSearchCriteria;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItemLabel;
private DevExpress.XtraLayout.LayoutControl layoutControlSummary;
private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroupSummary;
private DevExpress.Utils.ToolTipController toolTipMain;
private DevExpress.XtraEditors.ProgressBarControl progressBarSearch;
private DevExpress.XtraEditors.MarqueeProgressBarControl marqueeProgressBarControl;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchResults;
private DevExpress.XtraBars.BarButtonItem barButtonItemSearchAttachments;
private DevExpress.XtraBars.BarButtonItem barButtonItem1;
private DevExpress.XtraBars.BarButtonItem barButtonItemAssets;
private DevExpress.XtraBars.BarButtonItem barButtonItemSuppliers;
private DevExpress.XtraGrid.Views.Grid.EditFormUserControl editFormUserControl1;
private DevExpress.XtraEditors.LabelControl labelSummaryTitle;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem16;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItemImageBox;
private DevExpress.XtraBars.PopupMenu popupMenu1;
private DevExpress.XtraBars.PopupMenu popupMenu2;
public System.ComponentModel.ComponentResourceManager resources;
private DevExpress.XtraEditors.LabelControl labelControlSearchLogo;
Please investigate and advise, Thanks Dave Radcliffe
Update:
I have tried removing (commenting) various controls from this Form, with little or no change to the GDI handle counts.
Could it be that the DevExpress.XtraEditors.XtraForm itself is leaking these handles?
Hi David,
Thank you for your message.
I have tried to replicate the issue by creating an instance of XtraForm and then closing it, but haven't noticed leaking of GDI Handles. I have attached a video illustrating this. Please check it.
I suppose that on your side a tool for showing an application's GDI Handles shows you the growing number since the CLR garbage collector haven't collected unused objects yet. In my project, the garbage collector is invoked explicitly to show that GDI Handles are collected once the form is closed.
Would you please create a simple project or provide us with the problematic project illustrating GDI Handle leaks so we can examine it on our side?
I hope to hear from you soon.
Hello,
The attached solution creates 36 GDI handles when started.
When the button is clicked - showing a new mod al Form - the count goes up to 58.
After the Form closes, it is disposed , and the GC invoked, but the GDI handle count only drops by 8 to 50 (not back to 36).
Please advise.
Thank you, Dave R
Hi David,
Thank you for modifying the project. I have noticed the issue with the growth of GDI Handles. Please give me a little bit more time to investigate the cause of the issue. I will update this ticket once I have any results.
Hi David,
Thank you for waiting.
We have thoroughly reviewed your project project and found the cause of the GDI Handles growth. We noticed that even when the RibbonForm itself does not contain any controls on it, the controls are created since they are declared in the designer file. As a result, GDI handles of these controls are not released, since the controls are not placed on the RibbonForm.
I tried to replicate the issue by creating an instance of the Form and XtraForm classes, but all my attempts were unsuccessful. After the form is disposed, the number of GDI handles drops to the initial value.
However, when I tried to do the same with the RibbonForm, the result was different. We will continue our investigation and will get back to you as soon as we have any progress or results. Thank you for your patience.
Hi David,
We have fine-tuned our code. In a short time, I will provide you with a more detailed explanation and a hotfix build that you can install to test our changes. Please stay tuned.