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

Memory release problem with export to PDF

1 Answer 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
MikeK
Top achievements
Rank 1
MikeK asked on 07 Jul 2009, 07:38 PM
I have a report that I need to run automatically and generate sets of PDF files to specific folders on a network share drive, each with a unique name. I had setup a quick project with MS Access and was able to do this, although it's a bit buggy. For production I recoded the report into a Winform app using Telerik Reporting Q1 2009. The app does function as intended, but I noted that the machine gobbles all of the memory. I can watch the app run and as it's generating new PDFs, the memory use just continues to climb. I tried to do what I figured would release the memory, but it's not working.

Here's my code, did I miss something? How do I get the application to quit grabbing memory as it runs?

The report has 2 subreports included on the same page.

----Routine start---
        Dim con As New SqlConnection(My.Settings.CCO_MM_DATA)

        Dim sql As String = "usp_RptFaceSheet_ClientList_DIST"
        Try
            con.Open()
            Dim da As New SqlDataAdapter(sql, con)
            Dim ds As New DataSet
            da.Fill(ds)

            'Get Data Table
            Dim dt As DataTable = ds.Tables(0)

            'Display Data
            For Each row As DataRow In dt.Rows
                If Directory.Exists("S:\Development\FaceSheets\" & row(2).ToString) Then
                    Me.ReportViewer1.Report = New TestFaceSheet.Report1

                    TryCast(ReportViewer1.Report, TestFaceSheet.Report1).ReportParameters(0).Value = Int32.Parse(Trim(row(0).ToString))
                    Dim mimType As String = String.Empty
                    Dim extension As String = String.Empty
                    Dim encoding As Encoding = Nothing
                    Dim deviceInfo As Hashtable = New Hashtable
                    deviceInfo("FontEmbedding") = "None"
                    Dim buffer As Byte() = ReportProcessor.Render("PDF", ReportViewer1.Report, deviceInfo, mimType, extension, encoding)
                    Dim fs As New FileStream("S:\Development\FaceSheets\" & Trim(row(2).ToString) & "\[" & Trim(row(1).ToString) & "]ClientInfo.pdf", FileMode.Create)
                    fs.Write(buffer, 0, buffer.Length)
                    fs.Flush()
                    fs.Close()
                    deviceInfo.Clear()
                    fs.Close()
                    ReportViewer1.Dispose()

                End If

            Next
            con.Close()

        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()

        End Try
        End
----Routine end----

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 08 Jul 2009, 11:57 AM
Hello MikeK,

Currently we do not have any caching mechanism and every time the report is previewed, paged or exported through the viewer it is processed and rendered from scratch. Our current goal is to cover some reporting functionality we still lack and then we will move to the performance optimizations and productivity which are already in our TODO list and we hope we will soon have the chance to work on it.
Nevertheless we're improving the performance with every single release and Q2 2009 is not an exception, so we highly recommend upgrading to it.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
MikeK
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or