FIX: Memory leak in an MFC application that is developed in Visual Studio 2010 SP1 when the CPngImage::LoadFromBuffer method is used


Symptoms


Consider the following scenarios.

Scenario 1

  • You run a Microsoft Foundation Class (MFC) application that is developed in Microsoft Visual Studio 2010 Service Pack 1 (SP1).
  • The MFC application uses Portable Network Graphics (PNG) images as resources by repeatedly calling the internal CPngImage::LoadFromBuffer method.

Scenario 2

  • You run an MFC application that is developed in Microsoft Visual Studio 2010 SP1.
  • The MFC application calls the CMFCRibbonBar class to implement ribbon bars.

    NoteThe CMFCRibbonBar class for ribbon bars calls the CPngImage::LoadFromBuffer method.
  • The ribbon bars contain categories and buttons that use PNG images as resources.
  • You repeatedly open and close a document that has customized ribbon bars.
In these scenarios, a memory leak occurs in the MFC application. Therefore, the memory usage of the application increases.

Cause


This issue occurs because memory is not freed. This memory is allocated by the CreateStreamOnHGlobal function in the CPngImage::LoadFromBuffer method.

Note The expected behavior is that the memory is freed after a stream is released. This stream is created by the CreateStreamOnHGlobal function.

Resolution



Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft website:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.


Prerequisites

To apply this hotfix, you must have Visual Studio 2010 SP1 installed.

Restart requirement

You may have to restart the computer after you install this hotfix if the affected files are being used.

File information

The global version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

For all supported x86-based versions of Microsoft Visual C++ 2010 SP1 Redistributable Package

File nameFile versionFile sizeDateTimePlatform
Atl100.dll10.0.40219.332138,05611-Jul-201110:57x86
Mfc100.dll10.0.40219.3324,397,38411-Jul-201110:57x86
Mfc100chs.dll10.0.40219.33236,17611-Jul-201110:57x86
Mfc100cht.dll10.0.40219.33236,17611-Jul-201110:57x86
Mfc100deu.dll10.0.40219.33264,33611-Jul-201110:57x86
Mfc100enu.dll10.0.40219.33255,12011-Jul-201110:57x86
Mfc100esn.dll10.0.40219.33263,82411-Jul-201110:57x86
Mfc100fra.dll10.0.40219.33264,33611-Jul-201110:57x86
Mfc100ita.dll10.0.40219.33262,28811-Jul-201110:57x86
Mfc100jpn.dll10.0.40219.33243,85611-Jul-201110:57x86
Mfc100kor.dll10.0.40219.33243,34411-Jul-201110:57x86
Mfc100rus.dll10.0.40219.33260,75211-Jul-201110:57x86
Mfc100u.dll10.0.40219.3324,422,99211-Jul-201110:57x86
Mfcm100.dll10.0.40219.33281,74411-Jul-201110:57x86
Mfcm100u.dll10.0.40219.33281,74411-Jul-201110:57x86
Msvcp100.dll10.0.40219.332421,20011-Jul-201110:57x86
Msvcr100_clr0400.dll10.0.40219.332773,96811-Jul-201110:57x86
Vcomp100.dll10.0.40219.33251,02411-Jul-201110:57x86
For all supported x64-based versions of Microsoft Visual C++ 2010 SP1 Redistributable Package

File nameFile versionFile sizeDateTimePlatform
Atl100.dll10.0.40219.332158,53611-Jul-201110:14x64
Mfc100.dll10.0.40219.3325,574,98411-Jul-201110:14x64
Mfc100chs.dll10.0.40219.33236,17611-Jul-201110:14x64
Mfc100cht.dll10.0.40219.33236,17611-Jul-201110:14x64
Mfc100deu.dll10.0.40219.33264,33611-Jul-201110:14x64
Mfc100enu.dll10.0.40219.33255,12011-Jul-201110:14x64
Mfc100esn.dll10.0.40219.33263,82411-Jul-201110:14x64
Mfc100fra.dll10.0.40219.33264,33611-Jul-201110:14x64
Mfc100ita.dll10.0.40219.33262,28811-Jul-201110:14x64
Mfc100jpn.dll10.0.40219.33243,85611-Jul-201110:14x64
Mfc100kor.dll10.0.40219.33243,34411-Jul-201110:14x64
Mfc100rus.dll10.0.40219.33260,75211-Jul-201110:14x64
Mfc100u.dll10.0.40219.3325,601,61611-Jul-201110:14x64
Mfcm100.dll10.0.40219.33293,00811-Jul-201110:14x64
Mfcm100u.dll10.0.40219.33293,00811-Jul-201110:14x64
Msvcp100.dll10.0.40219.332608,08011-Jul-201110:14x64
Msvcr100_clr0400.dll10.0.40219.332829,26411-Jul-201110:14x64
Vcomp100.dll10.0.40219.33257,16811-Jul-201110:14x64
For all supported IA-64based versions of Visual C++ 2010 SP1 Redistributable Package

File nameFile versionFile sizeDateTimePlatform
Atl100.dll10.0.40219.332385,35211-Jul-201110:37IA-64
Msvcp100.dll10.0.40219.332966,48011-Jul-201110:37IA-64
Msvcr100_clr0400.dll10.0.40219.3321,499,47211-Jul-201110:37IA-64
Vcomp100.dll10.0.40219.332143,18411-Jul-201110:37IA-64

More Information



For more information about this issue in Microsoft Visual Studio 2008, click the following article number to view the article in the Microsoft Knowledge Base:
982637 A memory leak occurs in an MFC application that is developed by using Visual Studio 2008 SP1 when the CPngImage::LoadFromBuffer method is used

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.