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----
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----