Home Dashboard Directory Help

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


 as Fixed Help for as Fixed

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
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.
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.