Possibility to stream export to PDF

Stimulsoft Reports.NET discussion
Post Reply
postgres
Posts: 5
Joined: Fri Mar 04, 2022 10:22 am

Possibility to stream export to PDF

Post by postgres »

Hello,
I working on a machine with limited memory, and am trying to generate simple report, and then export it do PDF. Output report is around 8MB, but generating and exporting it to PDF, causes memory jump to over 1.5GB. Is there any way to stream rendering and exporting process, so memory is not allocated in such amounts? This is really big issue for me, because size of my reports is only going to grow. This is really weird that 8MB report allocates 1.5GB.

To reproduce, in empty template add PostgreSQL database and as SQL query:

Code: Select all

select
    left(md5(i::text), 10) as "Id",
    md5(random()::text) as "two",
    md5(random()::text) as "three",
    left(md5(random()::text), 4) as "four"
from generate_series(1, 80000) s(i)
add simple databand with those columns.

I am exporting rendered report like this:

Code: Select all

StiNetCoreReportResponse.ResponseAsPdf(stiReport, pdfSettings, false);
Lech Kulikowski
Posts: 7338
Joined: Tue Mar 20, 2018 5:34 am

Re: Possibility to stream export to PDF

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
Lech Kulikowski
Posts: 7338
Joined: Tue Mar 20, 2018 5:34 am

Re: Possibility to stream export to PDF

Post by Lech Kulikowski »

Hello,

Please send us a sample report for analysis.

Also, please clarify which product, version, framework, system, etc are you use?

Thank you.
postgres
Posts: 5
Joined: Fri Mar 04, 2022 10:22 am

Re: Possibility to stream export to PDF

Post by postgres »

I am using Stimulsoft.Reports.Web.NetCore 2022.1.6 on .NET5/6, Windows (same thing is on Linux also)
Attachments
ReportExample.mrt
(7.22 KiB) Downloaded 277 times
Lech Kulikowski
Posts: 7338
Joined: Tue Mar 20, 2018 5:34 am

Re: Possibility to stream export to PDF

Post by Lech Kulikowski »

Hello,

We couldn't reproduce the issue on our samples.

Please check the last release build 2022.2.1

Thank you.
postgres
Posts: 5
Joined: Fri Mar 04, 2022 10:22 am

Re: Possibility to stream export to PDF

Post by postgres »

I'm attaching project where you can see allocations, created by generating and exporting this report.

In archive, you'll also find 2 diagnostic sessions, that you can open in VS, and see that 1 report generation, with Server GC disabled (my initial post was when application was running with Server GC enabled), allocated around 450MB, for report that exported to PDF is 8MB is size. To run example you may need to alter database connection string.

The thing is that we are running Stimulsoft as a report generation server, and at one given moment we can have multiple reports of this, or bigger size generating and exporting, and we are running out of memory, and application crashes.

In Rider, Dynamic Program Analysis Shows multiple allocation issues, regarding exporting to PDF alone:
https://imgur.com/RXU6Tmd
with following stack trace (there is much more):

Code: Select all

at DeflaterEngine..ctor(DeflaterPending)
at Deflater..ctor(int, bool)
at StiExportUtils.MakePdfDeflateStream(byte[])
at StiPdfExportService.RenderPageFooter(double, double)
at StiPdfExportService.ExportPdf1(StiReport, Stream, StiPdfExportSettings)
at StiPdfExportService.ExportPdf(StiReport, Stream, StiPdfExportSettings)
at StiNetCoreReportResponse.ResponseAsPdf(StiReport, StiPdfExportSettings, bool)
at StiNetCoreReportResponse.ResponseAsPdf(StiReport, StiPagesRange, float, float, bool, bool, bool, String, String, StiUserAccessPrivileges, StiPdfEncryptionKeyLength, bool, bool)
at StiNetCoreReportResponse.ResponseAsPdf(StiReport, StiPagesRange, float, float, bool, bool, bool)
at Program+<<<Main>$>g__GenerateReport|0_0>d.MoveNext() in C:\Users\--\Documents\projects\ConsoleApp3\ConsoleApp3\Program.cs:line 29 column 9
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.ExecutionContextCallback(Object)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext(Thread)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext()
at StiReport.RenderAsync()
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.ExecutionContextCallback(Object)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext(Thread)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext()

Code: Select all

at StiPdfExportService.ConvertToEscapeSequence(String)
at StiPdfExportService.RenderText(StiPdfData, Nullable)
at StiPdfExportService.ExportPdf1(StiReport, Stream, StiPdfExportSettings)
at StiPdfExportService.ExportPdf(StiReport, Stream, StiPdfExportSettings)
at StiNetCoreReportResponse.ResponseAsPdf(StiReport, StiPdfExportSettings, bool)
at StiNetCoreReportResponse.ResponseAsPdf(StiReport, StiPagesRange, float, float, bool, bool, bool, String, String, StiUserAccessPrivileges, StiPdfEncryptionKeyLength, bool, bool)
at StiNetCoreReportResponse.ResponseAsPdf(StiReport, StiPagesRange, float, float, bool, bool, bool)
at Program+<<<Main>$>g__GenerateReport|0_0>d.MoveNext() in C:\Users\--\Documents\projects\ConsoleApp3\ConsoleApp3\Program.cs:line 29 column 9
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.ExecutionContextCallback(Object)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext(Thread)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext()
at StiReport.RenderAsync()
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.ExecutionContextCallback(Object)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext(Thread)
at AsyncTaskMethodBuilder+AsyncStateMachineBox<VoidTaskResult,StiDictionary+<SynchronizeAsync>d__105>.MoveNext()
Isn't there any way of optimizing those allocations?
Attachments
ConsoleApp3.zip
(11.46 MiB) Downloaded 310 times
Lech Kulikowski
Posts: 7338
Joined: Tue Mar 20, 2018 5:34 am

Re: Possibility to stream export to PDF

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
postgres
Posts: 5
Joined: Fri Mar 04, 2022 10:22 am

Re: Possibility to stream export to PDF

Post by postgres »

Hi, any updates?
Lech Kulikowski
Posts: 7338
Joined: Tue Mar 20, 2018 5:34 am

Re: Possibility to stream export to PDF

Post by Lech Kulikowski »

Hello,

We couldn't reproduce the issue. Please check the last release build.

Thank you.
Post Reply