Page 1 of 1

Possibility to stream export to PDF

Posted: Tue Mar 22, 2022 1:53 pm
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);

Re: Possibility to stream export to PDF

Posted: Wed Mar 23, 2022 12:33 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: Possibility to stream export to PDF

Posted: Wed Mar 23, 2022 12:41 pm
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.

Re: Possibility to stream export to PDF

Posted: Fri Mar 25, 2022 10:11 am
by postgres
I am using Stimulsoft.Reports.Web.NetCore 2022.1.6 on .NET5/6, Windows (same thing is on Linux also)

Re: Possibility to stream export to PDF

Posted: Mon Mar 28, 2022 9:25 pm
by Lech Kulikowski
Hello,

We couldn't reproduce the issue on our samples.

Please check the last release build 2022.2.1

Thank you.

Re: Possibility to stream export to PDF

Posted: Tue Mar 29, 2022 8:00 am
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?

Re: Possibility to stream export to PDF

Posted: Wed Mar 30, 2022 7:22 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: Possibility to stream export to PDF

Posted: Thu Apr 07, 2022 10:27 am
by postgres
Hi, any updates?

Re: Possibility to stream export to PDF

Posted: Mon Apr 11, 2022 12:58 pm
by Lech Kulikowski
Hello,

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

Thank you.