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

How to avoid out of memory exception

5 Answers 389 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marko Gluhak
Top achievements
Rank 1
Marko Gluhak asked on 21 Nov 2013, 03:59 PM
Hi,

I come across out of memory expetion in my application.I'm not using large amount of data.
Scenario:
I have application that need to print draw for martial art fights. There are over 100 categories and each category is on 1 page (up to 32 players) and on more then 1 if there are more then 32 players in category. Each category has its own report. Report is basicly manualy drawn draw (textboxes and lines). For example for 32 players draw I have 160 texboxes and each ot them has 2 or 3 conditinal formating and 2 of those conditional formating is also using backgroung image (images are taken from global::resource and not from report). When I render each report one by one everthing is fine. Problem comes when I need to create PDF with all drawns in it (100+pages).
I use ReportBook and in foreach statement I'm adding report to ReportBook. After that foreach statement I have this code but application does not  come to that part.
ReportProcessor reportProcessor = new ReportProcessor( );
 
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource( );
 
var reportToExport = reportBook;
instanceReportSource.ReportDocument =reportToExport;
 
RenderingResult result = reportProcessor.RenderReport( "PDF", instanceReportSource, null );
string fileName = result.DocumentName + "." + result.Extension;
 
Response.Clear( );
Response.ContentType = result.MimeType;
Response.Cache.SetCacheability( HttpCacheability.Private );
Response.Expires = -1;
Response.Buffer = true;
 
Response.AddHeader( "Content-Disposition", string.Format( "{0};FileName=\"{1}\"", "attachment", fileName ) );
 
Response.BinaryWrite( result.DocumentBytes );
Response.End( );

Is there any way that I actualy render 1 report at time and then just glue them in 1 PDF (like I create 100+ individual reports and then save them all in 1 PDF).
When I watch for memory, this PDF creating takes from 200MB memory up to 2,6 GB and then gives me "parameter is null" error on screen but when I debug application details says "out of memory". There is still more phisical memory free on server. I dont know what is taeking 2,6 GB of memory and final result is 300 kb PDF.

Please help.

5 Answers, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 26 Nov 2013, 04:22 PM
Hi Marko,

Although your report does not include lots of data, it seems quite complex and this is the reason that it takes lots of memory during processing. You can check the Performance Considerations documentation article to see if you can reduce the processing workload.

For example, the images you use as a background should be processed and despite the fact that they are loaded externally, they reside in memory during the processing. You can try to remove them just to see if they consume too much memory and then probably replace it with images with lower resolution.

Since you are dumping the data, using filtering and report parameters is probably irrelevant, but you can also consider simplifying the report structure.

Also please note that if you are using InProc session state mode, the memory of the worker process is used and the report instance is kept in the session. You might consider changing your state mode to Out-Proc, which will require a bit more effort, as you can see in the Design Considerations for Out-proc Session State article.

Hope it helps.

Regards,
Ivan Hristov
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Marko Gluhak
Top achievements
Rank 1
answered on 27 Nov 2013, 09:24 PM
Is there and diference If I use i image as backgound that will mimic structure of draw or I use textboxex and set borders on them. I need to use textboxes wether but what I want to know is rendering textboxes without borders less performance problem. Images that I use in reports are about 1kb.

I have read tips for performance and only thing I can think of is to devide report in subreports but this is logical problem as all data are for 1 draw and needs to be on 1 page.
0
Ivan Hristov
Telerik team
answered on 29 Nov 2013, 02:39 PM
Hi Marko,

Drawing borders around textboxes is definitely less resource-consuming, in comparison to background image usage, because the borders drawing is done in the format native elements and does not involve any additional resources.

Please give it a try and let us know if it solves your problem.

Regards,
Ivan Hristov
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
bhawna
Top achievements
Rank 1
answered on 10 May 2017, 10:26 AM
I am using Telerik reporting in my .Net application hosted on Azure as PAAS. I have build a report using telerik, but while rendering the contents it throws an out of memory error. Please suggest ways to fix this error.
0
Stef
Telerik team
answered on 12 May 2017, 02:13 PM
Hi bhawna,

Please check if the problem occurs only when you export in PDF. If yes, check this KB article - GDI+ error or OutOfMemoryException on exporting or printing Telerik report from Azure WebSites.

If the error occurs when you request the report in a web viewer (in HTML format), please test switching the viewer's ViewMode to PRINT_PREVIEW, which should deliver the report in pages, since some browsers like IE have a limitation about the number of HTML elements in a page - Browsers Limitations.


If the error occurs in all rendering formats, please test of reducing the amount of data helps. If yes, the number of used instances cannot handle the amount of data that is processed in reports (this includes the resources for the documents generation) - Performance Considerations.

Regards,
Stef
Telerik by Progress
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
Marko Gluhak
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Marko Gluhak
Top achievements
Rank 1
bhawna
Top achievements
Rank 1
Stef
Telerik team
Share this question
or