Re: Memory...issues

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Sep 26, 2:44 pm, "James" <n...@xxxxxxxx> wrote:
I have a record set of roughly 1200 records. The logic flow is like this:

Dim ds As New DataSet
Dim da As New SqlDataAdapter("SELECT * FROM Fax_Queue", objConnection)
da.Fill(ds, "Queue")

Dim dr As DataRow
Dim rpt as FaxReport = New FaxReport

For Each dr In ds.Tables("Queue").Rows
rpt.listid = dr("List_ID")
rpt.Run(False)
Dim xTIFF As DataDynamics.ActiveReports.Export.TIFF.TiffExport = New
DataDynamics.ActiveReports.Export.Tiff.TiffExport

tiffPath = path & ".tiff"
xTIFF.Export(rpt.Document, tiffPath)
xTIFF.Dispose()
GC.Collect() ' ???

Dim del As New SqlCommand("DELETE FROM Tbl_Collection_Fax_Queue
WHERE Queue_ID = " & dr("Queue_ID"), objConnection)
objConnection.Open()
del.ExecuteNonQuery()
objConnection.Close()
Next

As this application progresses and the TIFF files are generated, the memory
consumed by this process increases to a point where it basically locks up.
How can I prevent this memory leak? Is there a logic problem or can I
forcibly release memory somehow? In my head this process should be
consuming roughly the same amount of memory consistently.

Thanks for any help you can offer,
James

James,

What version of the runtime are you working with here? Also, might I
suggest that you not use a DataSet here... You are working with one
record at a time in a forward only manner, I believe you will see much
improved performance and reduce some of the memory pressure since you
won't have all 1200 records in memory at once. Also, you might want
to avoid the open/closes of the data connection. With connection
pooling, you probably aren't being hurt to much but, it seems sort of
pointless in this case. I would open the connection, run your process
and close the connection when your done. You should probably avoid
calling GC.Collect as well...

Ok... Another question? Do you run this procedure often? In rapid
succession? You might want to get ahold of a profiler. There are
several out there, and a couple of them are free or have free trials
(I've used Ants profiler in the past with very good success, but
YMMV). This may boil down to a bug in a 3rd party component, but
profiling the application will give you a good idea of where and why
the memory is being consumed.

Anyway, just some random thoughts on optimization and trouble
shooting :)

HTH

--
Tom Shelton

.



Relevant Pages

  • Re: Memory...issues
    ... Can you try what happens if you place the creating and accessing of your xTiff in a seperate method. ... Dim ds As New DataSet ... Dim rpt as FaxReport = New FaxReport ... As this application progresses and the TIFF files are generated, the memory consumed by this process increases to a point where it basically locks up. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Memory "leaking" from ADO!!! Help!
    ... Dim cnn as ADODB.Connection ... That will release all of the memory being used by those objects. ... > // typical connection string: ... /* here goes the code to set up the SQL string */ ...
    (microsoft.public.vc.database)
  • Re: Memory "leaking" from ADO!!! Help!
    ... Dim cnn as ADODB.Connection ... That will release all of the memory being used by those objects. ... > // typical connection string: ... /* here goes the code to set up the SQL string */ ...
    (microsoft.public.sqlserver.programming)
  • Re: Memory "leaking" from ADO!!! Help!
    ... Dim cnn as ADODB.Connection ... That will release all of the memory being used by those objects. ... > // typical connection string: ... /* here goes the code to set up the SQL string */ ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Memory "leaking" from ADO!!! Help!
    ... Dim cnn as ADODB.Connection ... That will release all of the memory being used by those objects. ... > // typical connection string: ... /* here goes the code to set up the SQL string */ ...
    (microsoft.public.data.ado)