Cache / Memory problem with ReportViewer in

2 posts, 0 answers
  1. Fabian
    Fabian avatar
    3 posts
    Member since:
    Oct 2012

    Posted 09 Dec 2014 Link to this post


    I have a big Report with a lot of objects ( > 100'000) get processed in a report. This works fine on the first time but the memory usage is very high. (>200mb). I inspected a lot of possible reasons and found out that the all my objects in the datasource for my report get cached by the reportviewer. As i'm loading the data from a database after interaction from a user (filter, export etc.) i don't need this cache. 
    Because of the cache the memory is not getting released until the cache is released and that could be a long time. So if i run my report multiple times i got in trouble with the high memory usage ( > 2.5 GB).

    What can i do? I tried to move the cache ( to the file system but this is not working as expected.

    Best regards
  2. Stef
    Stef avatar
    3610 posts

    Posted 12 Dec 2014 Link to this post

    Hi Fabian,

    This is the designed behavior of the ASP.NET ReportViewer control.

    In general, the control uses the ASP.NET Session and ASP.NET Cache to preserve report's resources and state. The objects saved in the Session and Cache are not cleared until the corresponding objects are not released. To resolve the issue you can set shorter expiration time for the Cache.

    Still our recommendation is to switch to the new HTML5 Report Viewer and the Reporting REST service, where the report's state and resources are preserved entirely in an external cache storage defined in the service's storage methods.

    In general, the HTML5 Report Viewer is a client-side widget served only by a running Reporting REST service, which is dedicated to display already created reports. It is the service that manages the report state and resources. More details how the viewer and the service work, and how to set them manually in a project are available in this forum thread (all tutorials for using the viewer and the service are linked in the thread).

    Details how to add the viewer via template are available in the HTML5 Report Viewer Quickstart article

    How the viewer(client)-service pair works:

    Basically, the client (viewer) sends string description of the requested report (the viewer's value) to the service, and depending on the report resolvers in the service's CreateReportResolver method this string description will be resolved to a report source object.
    By default we provide ReportFileResolver and ReportTypeResolver. You can also create your own report resolvers as in the example in the How To: Implement a Custom Report Resolver article.

    Depending on how the application will be hosted, you can use the corresponding cache storage for the service - REST Service storage. If the service will be hosted separately, and will use a different domain you may need to enable CORS to allow the communication between the clients(viewers) and the service.

    For a working demo, check the local examples installed by default under C:\Program Files (x86)\Telerik\Reporting <VERSION>\Examples\CSharp.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top