Bug Report T367803
Visible to All Users

RibbonForm - The number of GDI Handles increases after the form was opened and closed several times

created 9 years ago (modified 9 years ago)

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

Show previous comments (3)
Alisher (DevExpress Support) 9 years ago

    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.

    Alisher (DevExpress Support) 9 years ago

      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.

      Alisher (DevExpress Support) 9 years ago

        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.

        Answers approved by DevExpress Support

        created 9 years ago (modified 9 years ago)

        Hi David,

        We have tuned our sources and the RibbonControl class in particular, so now GDI leaks should not occur.

        You may, however, still notice the behavior when the number of user handles and GDI handles is increased after the RibbonForm was shown and is not decreased when the RibbonForm is closed. This behavior is correct and does not lead to leaks in GDI or user handles. For proper work, the ribbon creates additional handles for fonts and cursors in the BarAndDockController object. These objects are created once and used until the application is closed.

        Additionally, the number of handles may be increased by one each time you show and close the RibbonForm. This happens since we are using a font different from the default font. An instance of this font is created in the form's constructor. This specificity causes the growth of GDI handles. You can, however, force your application to use the default font. Set the DevExpress.XtraEditors.WindowsFormsSettings.FontBehavior  property to WindowsFormsFontBehavior.UseControlFont for this. Once the property is set, the issue will disappear. The behavior with increasing handles is reproducible with the standard forms as well, and I recorded a video to illustrate this. But, there are no reasons to worry. Our forms are descendants of the standard Form class and the standard Form's internal mechanism collects unused handles once the time for finalization has come.

        You are always welcome to share the problematic project so we can examine leaks in it.

          Comments (2)
          DR DR
          David Radcliffe 9 years ago

            I requested a hotfix, thinking it would be for 2015.1.8 -the version we use in production.

            The confirmation email states it is for 2015.2.10 - we don't need this, as we don't use this version.
            If that is the case, this hotfix request can be cancelled.

            Thanks, Dave

            Alisher (DevExpress Support) 9 years ago

              David,

              We have made these changes in version 15.2 of our components only.

              created 9 years ago

              We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

              Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.