Possible Memory Leak


06-29-2010, 1:40 PM
In more testing leading to a final release, we where trying to run large datasets to see how it performs.

We noticed however that the memory consumption in the w3wp.exe goes up with each report run and that memory never seems to be released.

I have attached a sample report with a single column dataset with 70000 rows. This is output to a simple report with a table.

Using the web viewer the first run consumes over 1 GB ram! Subsequent runs consume about 250MB ram. Refreshing the web viewer a few times will quickly exhaust the 4GB of ram on my development machine.

As far as I can tell the memory is never released, so long as the worker process is not recycled the ram usage will never go down, as though the report runs are not being garbage collected.

I tried using the VaryBy property of the viewer to adjust caching, but it seemed to have no effect, and it does not have a setting to turn off caching completely.

The Winform viewer seems to suffer from this too, simply loading the rdlx up and refreshing the report will pretty quickly exhaust my workstation ram. Interestingly enough the Winform viewer is actually MUCH slower at rendering the report than the web viewer!

Now this type of data set is not typical for our users, but sometimes they may need to dump large amount of data into Excel for post analysis. However I believe the issue exist on all size datasets, and in a production install a higher volume of smaller datasets will quickly exhaust web server ram.

The sample I have attached has a dataset serialized to xml that it uses as a datasource, but the issue occurs with a sqlserver data source as well.

Is there anything more I need to do to release memory?

Re: Possible Memory Leak


06-30-2010, 11:05 AM
Justin,

Thanks for such a detailed explanation of the issue.

I am currently researching further on this and will post my observations soon.
Amit Pal
GrapeCity- DataDynamics

Re: Possible Memory Leak


07-08-2010, 1:54 PM
Any status update?

Where you able to reproduce the memory usage issue there?

Re: Possible Memory Leak


07-14-2010, 4:58 AM
Hello,

We have looked further into this on couple of machines (Windows 2003 and Windows 2008 Server) by running your sample and the maximum memory usage I am seeing is around 310 MB on both the machines. I have used a Memory profiler to test this issue.

Which memory profiler are you using to see this memory leak?
Which Operating system is installed on the machine?
I have tested this issue with the latest version (1.6.1871.24). Which version is installed on your machine?
Amit Pal
GrapeCity- DataDynamics

Re: Possible Memory Leak


07-14-2010, 1:30 PM
Using the latest version 1.6.1871.24.

Window 7 64bit 4gigs of ram.

I am working on a memory profile in VS2010 but it is taking some time.

Perhaps the web viewer example wasn't the best example to post, I am putting together a simple winform that simply loads the report and does a ReportRefresh in the RenderingCompleted event. You can simply let it run and it will exhaust all memory on the machine after a few runs (about ~450MB used per run).

Until I get the memory profile here is a screenshot of Task Manager after refreshing the report 3 times in your pre-built Report Previewer.

You should be able to replicate by just loading the RDLX in the previewer and refreshing it.

Re: Possible Memory Leak


07-14-2010, 1:35 PM
Another thing to note if testing the webviewer in IIS is that I believe by default IIS will recycle the app pool if the process uses more than a certain percentage of main memory.

This will appear to free the memory, which it is, but only because the whole process is shutdown and a new worker is spun up in its place.

You have to make sure the process ID is not changing when profile the memory in that situation.

Of course the eaiser thing to do is run the report in the winform viewer, as the process is static and under the apps control.

Re: Possible Memory Leak


07-15-2010, 7:27 AM
Justin,

(1) I ran the report with the steps you have provided on Windows 7 64 bit machine (2GB RAM) and the ReportViewer takes maximum 345 MB and on subsequent refresh of the report, the memory usage more or less remains constant. I will wait for the sample windows forms application from your side to debug this further.

(2) You are correct and we were not using a different process ID however using the same process ID all the time.
Amit Pal
GrapeCity- DataDynamics

Re: Possible Memory Leak


07-15-2010, 2:53 PM
Attached is a self contained Winform solution to reproduce the issue.

You can simply run the executable in the bin folder, or rebuild.

It runs the report with dataset I provided before over and over.

On all machines tested here so far, Win 7 64bit and win 2003 32bit, this application will eventually consume all available memory and crash with and OutOfMemoryException.

I will post a csv dump of a RedGate ANTS memory profile of 5 report runs.

Re: Possible Memory Leak


07-15-2010, 2:56 PM
Here is the ANTS Memory Profile in CSV format, it look like most of the memory is used by a class name #Z2e which is some kind of expression evaluation form the report engine.

Re: Possible Memory Leak


07-15-2010, 3:05 PM
Here is a screenshot of ANTS Summary for completeness, notice on the timeline you can see the report run boundaries and how heap size just keeps growing.

Re: Possible Memory Leak


07-15-2010, 3:19 PM
Here is a screenshot of the heap summary, showing most bytes are in the Gen 2 heap.

Re: Possible Memory Leak


07-15-2010, 9:51 PM
Hello,
I start working on the memory problem immediately. I'll constantly post the updates in this thread.

Sergey Abakumoff
GrapeCity

Re: Possible Memory Leak


07-19-2010, 3:07 AM
Update: we are aggressively working on the fix. It is not 1 line improvement of the code, so we have not complete the fix yet. I'll keep the post updated.

Sergey Abakumoff
GrapeCity

Re: Possible Memory Leak


07-21-2010, 4:16 AM
Hello,
I've sent you the email that contains the download link for the build that has the fix for the memory leak issue on web-viewer.
Could you please confirm that you received the e-mail?

Sergey Abakumoff
GrapeCity

Re: Possible Memory Leak


07-21-2010, 11:37 AM
I have been running test with the new build and it seems to properly garbage collect memory after refreshing the web report viewer.

Ram usage on this report seems to hold around 320-500 megs of ram in the asp.net development web server and around 1 Gigs of ram running on IIS7 in its own application pool.

So this seems to have resolved releasing memory between runs.

We are still somewhat concerned with the amount of memory used for just one run, as the serialized data set is only 5MB, yet ends up being 100-200X that as a rendered report in ram. This seems excessive and if 3-4 users ran this report at once it could result in an out of memory exception on the web server.

Also as you already know the Winform viewer still suffers from this problem, but our application currently only uses the web viewer.

I believe this is satisfactory for our needs currently although less ram usage per run would be very desirable for larger datasets.

I also noticed that exporting to Word or Excel doesn't seem to work with this large of a data set either, I think this may be a separate issue and may have always been this way, I received as stack overflow exception exporting to Excel format after it ran for a while, and Word export never returned anything.

Thanks for the quick response.