We are experiencing a memory leak in one of our applications. It is a web-based reporting system that produces large (> 500mb) PDF reports. It takes approx 4 hours to run the largest of these reports and during this process we have been experiencing issues with the aspnet worker process being recycled as the application's memory keeps growing to around 600mb. From my investigation, it appears that the memory is becoming bloated with character and numeric data created from DataSets. Each iteration of the report process creates 6 DataSets and these iterations occur as many as 40000 times during the creation of the larger report. We are making sure that the DataSets are disposed of (we are even clearing the DataSets after use to try to ensure that their associated objects are freed) but I am finding that the aspnet processes memory is chock-full of the character and numeric data that I would expect to be contained in these DataSets.
Using ADPlus, I have taken a hang dump from the aspnet_wp process when it got to around 350mb of memory consumption. Upon analysing the dump file, I found that most of the memory is being taken up by millions of objects containing the data that is used in the reports (see below). I have run GCRoot on about 50 different objects, but it doesn’t return anything so now I am stuck. How can I find out why this data isn’t being collected and cleared?
Any help you have to offer is greatly appreciated!
...
0x79ba8cc8 9,015 108,180 System.Int32
0x79ba182c 5,472 131,328 System.Collections.ArrayList/ArrayListEnumeratorSimple
0x0be9fc58 4,160 133,120 System.Xml.DocumentXPathNavigator
0x79ba0d74 6,355 152,520 System.Collections.ArrayList
0x79bc2860 10,448 167,168 System.DateTime
0x79bbe7d0 13,977 167,724 System.Boolean
0x79ba968c 4,383 227,916 System.Collections.Hashtable
0x00be31e8 7,834 542,964 System.Int32[]
0x79bc1974 34,345 824,280 System.Decimal
0x00be34a8 4,508 1,009,248 System.Collections.Hashtable/bucket[]
0x0d5cbe4c 16,806 1,075,584 System.Data.DataColumnPropertyDescriptor
0x0e3d6cf4 30,193 1,207,720 System.Data.DataRow
0x00be6d9c 47 1,829,460 System.DateTime[]
0x0015da08 399 2,515,704 Free
0x00be236c 59,992 2,893,624 System.Char[]
0x00be292c 2,229 3,394,404 System.Byte[]
0x00be5fd4 251 21,703,896 System.Decimal[]
0x00be209c 23,881 27,103,640 System.Object[]
0x79b925c8 1,169,609 56,849,864 System.String