Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
FIX: Memory Leak When Throwing Exceptions from Nested Exception Blocks
Article ID: 810178 - View products that this article applies to.
When an exception error is thrown from a catch clause, the first exception object will leak.
For example, when an error occurs while the program is running, you might want to use a try-catch statement to handle the exception. However, if the code that handles the exception in the catch clause throws another exception, the first exception object will never be deleted by the .NET Framework garbage collector. This causes a memory leak in the calling process.
A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to computers that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next .NET Framework service pack that contains this fix.
To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=supportNOTE: 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 typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this fix has the file attributes (or later) 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 tool in Control Panel.
Date Time Version Size File name -------------------------------------------------------------- 16-Nov-2002 04:05 1.0.3705.378 69,632 Corperfmonext.dll 16-Nov-2002 14:28 1.0.3705.378 1,953,792 Mscorlib.dll 16-Nov-2002 03:56 10,272 Mscorlib.ldo 16-Nov-2002 04:04 1.0.3705.378 2,269,184 Mscorsvr.dll 16-Nov-2002 04:04 1.0.3705.378 2,269,184 Mscorwks.dll
Steps to Reproduce the BehaviorNote The following is minimal information that is relevant to demonstrate the problem that is discussed in this article.
To reproduce the problem, include the following code in a Visual C# .NET project, and then run it directly (not in the IDE or in any other debugger):
You will notice that this code leaks 2 garbage collection handles for each iteration.
You can monitor this behavior by looking at the following PerfMon counters:
(http://support.microsoft.com/kb/248345/EN-US/ )How to Create a Log Using System Monitor in Windows 2000
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Article ID: 810178 - Last Review: October 11, 2005 - Revision: 2.4