Search

GDI leak when closing last document tab in an MDI application by Patrick Scherz

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 718189
Opened: 1/12/2012 1:22:21 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
1
Workaround(s)
0
User(s) can reproduce this bug
In an MFC application with tabbed documents there will always stay 10 GDI font handles if you closed the only tab and opened a new document. It will only allocate those 10 handles if it is the first tab that is opened.

We discovered this error because we have to open and close very many documents sequentially. When we reach about the 950th iteration of opening and closing the only tab the gdi handle count reaches 10000 and the application raises a CResourceException.

Currently we are using a workaround to prevent this from happening. We open one empty document, then do our tasks and close this empty document afterwards.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

0. Get GDIView (preferred) or Sysinternal's ProcExplorer. Referred to as monitoring tool later.
1. Create a new MFC Application and ensure you are using the Multiple Documents type with tabbed documents
2. Compile
3. Run
4. Fire up the monitoring tool and search for your application
5. Take a note of your monitoring tool's reported GDI font handle count of your application
6. Close the last tab (so the tabbar disappears)
7. Create a new document
8. Compare the new GDI font count and observe the increase of 10 handles
9. repeat 6-9 until satisfied

Product Language

German

Operating System

Windows 7

Operating System Language

German

Actual results

GDI font handle increases by 10 every time the only tab is closed and a new document is created.

Expected results

The font handles should be freed if the only tab was closed.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 1/17/2012 at 11:45 AM
Hello Patrick,

Thanks for the report. This issue has been fixed in MFC for the next major release of Visual Studio. The MFC application can opt to reuse the CMFCTabCtrl windows in the MDI client area window via a new CMDITabInfo member variable named m_bReuseRemovedTabGroups.

Pat Brenner
Visual C++ Libraries Development
Posted by MS-Moderator09 [Feedback Moderator] on 1/12/2012 at 7:08 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 1/12/2012 at 1:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Patrick Scherz on 1/12/2012 at 1:24 AM
Leave at least one tab open.