FIX: Memory leak when you use the FileSystemWatcher class in a .NET Framework 4.0-based application

SYMPTOMS
When you use the FileSystemWatcher class in a Microsoft .NET Framework 4-based application to watch for changes in a specified directory, a memory leak occurs.
CAUSE
This issue occurs because of an error in the FileSystemWatcher class. When a FileSystemWatcher object is created, the FileSystemWatcher class uses the GCHandle class to create a pinned garbage collector (GC) handle. The handle is 8K bytes and uses the byte[] data format. However, the FileSystemWatcher object never frees the garbage collector handle. Therefore, the issue that is described in the "Symptoms" section occurs.
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 the .NET Framework 4 installed.

Restart requirement

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

We recommend that you close all .NET Framework applications that lock or use the affected files before you install this hotfix.

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 the .NET Framework 4 for Windows Server 2003, for Windows XP, for Windows Vista, for Windows Server 2008, for Windows Server 2008 R2, or for Windows 7
File nameFile versionFile sizeDateTimePlatform
System.dll4.0.30319.5133,511,11210-Oct-201102:35x86
For all supported x64-based versions of the .NET Framework 4 for Windows Server 2003, for Windows XP, for Windows Vista, for Windows Server 2008, for Windows 7, or for Windows Server 2008 R2
File nameFile versionFile sizeDateTimePlatform
System.dll4.0.30319.5133,511,11210-Oct-201102:35x64
For all supported IA-64–based versions of the .NET Framework 4 for Windows Server 2003, for Windows Server 2008, or for Windows Server 2008 R2
File nameFile versionFile sizeDateTimePlatform
System.dll4.0.30319.5133,511,11210-Oct-201102:35IA-64
MORE INFORMATION
For more information about the FileSystemWatcher class, visit the following MSDN website:For more information about the GCHandle structure, visit the following MSDN website:
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Properties

Article ID: 2628838 - Last Review: 11/18/2011 01:28:00 - Revision: 2.0

Microsoft .NET Framework 4

  • kbqfe kbhotfixserver kbfix kbexpertiseadvanced kbsurveynew KB2628838
Feedback