Out of memory exception when saving large document
Posted: Wed Dec 18, 2019 9:11 am
Hello ,
When trying to save a large document to get mdc file , sometime occur exception ( out of memory exception)
Please see my code and exception :
Code
StiReport report = new StiReport();
report.Load(template);
report.AutoLocalizeReportOnRun = true;
report.ReportCacheMode = StiReportCacheMode.On;
report.RenderedPages.CacheMode = true;
report.RenderedPages.CanUseCacheMode = true;
report.Render(false);
MemoryStream stream = new MemoryStream();
report.SaveDocument(stream);
_______________________________
Excetion :
Exception of type 'System.OutOfMemoryException' was thrown. Stack trace: at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapacity(Int32 value) at System.IO.MemoryStream.WriteByte(Byte value) at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.CorrectRefs(MemoryStream input, Stream output, Int64 startPosition, Int64 endPosition, Int32 baseNewRef, Int32 baseOldRef) at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.SaveOptimized(Stream stream, StiDocument document, StiSerializing sr) at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.Save(StiReport report, Stream stream) at Stimulsoft.Report.StiReport.SaveDocument(StiDocumentSLService service, Stream stream) at Stimulsoft.Report.StiReport.SaveDocument(Stream stream) at WebFreight.Web.Helpers.ReportHelper.SetStiViewer(ReportFliter reportFliter, StiBusinessObject currentBusinessObject, Byte[] template, Byte[] logo)
Thanks.
When trying to save a large document to get mdc file , sometime occur exception ( out of memory exception)
Please see my code and exception :
Code
StiReport report = new StiReport();
report.Load(template);
report.AutoLocalizeReportOnRun = true;
report.ReportCacheMode = StiReportCacheMode.On;
report.RenderedPages.CacheMode = true;
report.RenderedPages.CanUseCacheMode = true;
report.Render(false);
MemoryStream stream = new MemoryStream();
report.SaveDocument(stream);
_______________________________
Excetion :
Exception of type 'System.OutOfMemoryException' was thrown. Stack trace: at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapacity(Int32 value) at System.IO.MemoryStream.WriteByte(Byte value) at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.CorrectRefs(MemoryStream input, Stream output, Int64 startPosition, Int64 endPosition, Int32 baseNewRef, Int32 baseOldRef) at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.SaveOptimized(Stream stream, StiDocument document, StiSerializing sr) at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.Save(StiReport report, Stream stream) at Stimulsoft.Report.StiReport.SaveDocument(StiDocumentSLService service, Stream stream) at Stimulsoft.Report.StiReport.SaveDocument(Stream stream) at WebFreight.Web.Helpers.ReportHelper.SetStiViewer(ReportFliter reportFliter, StiBusinessObject currentBusinessObject, Byte[] template, Byte[] logo)
Thanks.