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

Memory Leak in Telerik Reporting Service

1 Answer 227 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kanoo
Top achievements
Rank 1
Kanoo asked on 03 Mar 2018, 09:39 AM

I've web application and using AspNetCore 2.0. I'm using Telerik Reporting v12.0.18.125
I'm facing a memory leak issue in my system. After displaying the Report using Report Viewer the Report object is still in the memory heap and refreshing the report one time create more 3 report instances and it is never removed from the memory.
I'm using below CustomReportResolver to Resolve the report using DependencyInjection 

public class CustomReportResolver : IReportResolver
  {
      private readonly IIocResolver iocResolver;
      private readonly IAbpSession abpSession;
 
      public CustomReportResolver(IIocResolver iocResolver,IAbpSession abpSession)
      {
          this.iocResolver = iocResolver;
          this.abpSession = abpSession;
      }
 
      public ReportSource Resolve(string reportId)
      {
          var reportType = Type.GetType(reportId);
 
          if (reportType == null)
              throw new UserFriendlyException($"Could not find a corresponding report for type '{reportId}'.");
 
          var report = (Report) this.iocResolver.Resolve(reportType);
          var customReport = report as ReportBase;
          if (customReport != null)
          {
              customReport.TenntId = abpSession.TenantId;
              customReport.UserId = abpSession.UserId;
              customReport.IocResolver = this.iocResolver;
          }
 
          var reportSource = new InstanceReportSource {ReportDocument = report};
          return reportSource;
      }
  }

and this is the ReportsController

[ApiExplorerSettings(IgnoreApi = true)]
   public class ReportsController : ReportsControllerBase, ITransientDependency
   {
       public ReportsController(IHostingEnvironment environment, IIocResolver iocResolver, IAbpSession abpSession)
       {           
           this.ReportServiceConfiguration =
              new ReportServiceConfiguration
              {
                  HostAppId = "Html5DemoApp",
                  Storage = new FileStorage(),
                  ReportResolver = new CustomReportResolver(iocResolver,abpSession)
              };
       }
   }

I want to find a way to remove the Report Instance from the memory to avoid this memory leak issue.

Thanks,

 

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 07 Mar 2018, 03:03 PM
Hi Kanoo,

The Report Engine indeed needs more that one instance of the report to resolve parameters, process and render the report in the required format (pdf, doc, etc.) - check Report Life Cycle article.
Each Refresh/Preview re-generates the report, hence the new instances. The instances are released after the Report Engine has finished using them.

In .NET you are not supposed to release memory yourself, i.e. you don't get memory leaks in the traditional sense.
The Report Engine relies on the Garbage Collection to release the memory occupied by report instances. The unused report instance(s) would be eventually collected when/if any of the conditions for Garbage Collection is met.

Therefore we do NOT consider the creation of more than one instance of the report as a Memory Leak.

Each report instance occupies a small amount of memory that could hardly be critical for the application.
However, you are free to explicitly call GC.Collect() method to collect the released report instances. This would slow down the application though.

Regards,
Todor
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Kanoo
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or