This is a migrated thread and some comments may be shown as answers.

ReportViewer and memory management

1 Answer 213 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ernani Cecon
Top achievements
Rank 1
Ernani Cecon asked on 19 Mar 2010, 02:03 PM

After reading some threads about memory management in Telerik Reporting, I noticed that it is a known issue that memory management and performance on the component have some room for improvement. At this moment, I'm facing some challenges to keep the memory usage low when reports are generated, so that I can get my application more scalable and support more concurrent users, and I've been trying some stuff to get around the issue.

We are wondering if it would be a good idea to replace the usage of the ReportViewer control in our web page by using ReportProcessor.RenderReport, using HTML as the format. That way we can just place the resulting HTML on the page and release all resources. Here is how the code would look like:

//Note: "ec" below is my Telerik report class
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();  
Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("HTML", ec, null);  
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();  
string htmlResult = enc.GetString(result.DocumentBytes);  
reportProcessor = null;  
result = null;  
lblResult.Text = htmlResult;

We thought this approach could be good for two reasons:

1. The call to RenderReport is synchronous and runs on the same thread as the page - that way I have control of when the render finishes, so I can release the resources after everything is done. The call to ReportViewer.RefreshReport() doesn't work that way, as per our observation (seems to run on a separate thread, so we have no way of capturing the moment the report finishes rendering to clear resources).
2. We don't want/need the toolbar provided by the ReportViewer component.

I'd like an opinion from Telerik on the approach above. Does it make sense?

Another question: the code above renders only the first page of the report in HTML. Is there a way I can get the other pages? I couldn't find information about this on the documentation of the RenderReport method.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 23 Mar 2010, 03:47 PM
Hello Ernani Cecon,

Although it is possible to render a report to HTML format using the ReportProcessor.Render method I would not recommend that. The ReportViewer control handles the report rendering possibly in the best way and whatever you do you will end up with something similar.

Have in mind that the report may contain resources such as images which cannot be streamed together with the html markup so you will need to store them somewhere in memory and handle somehow the subsequent requests for them. This is also true for reports that contain multiple pages: again you will have to store somewhere the html of the invisible pages.

I have implemented a very basic example to illustrate that.  You can experiment with the attached sample page in order to see how actually everything works and maybe try another approach. I hope this will help you decide which way fits best your needs.

Sincerely yours,
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
General Discussions
Asked by
Ernani Cecon
Top achievements
Rank 1
Answers by
Telerik team
Share this question