Out of Memory Exception

J

James

Should be an easy one for you veterans. Have a DataSet that I'm looping
through with a For Each loop. There are 500+ records in this DataSet. For
each record, I'm creating a PDF by exporting an ActiveReport. So the basic
logic flow is:

Dim rpt As Main = New Main ' This is the activereport

For Each dr In dv.Table.Rows
<set rpt values here>
rpt.Run(False)

Dim xPDF As DataDynamics.ActiveReports.Export.Pdf.PdfExport = New
DataDynamics.ActiveReports.Export.Pdf.PdfExport
xPDF.Export(rpt.Document, mStream)
pdfPath = Request.PhysicalApplicationPath & "\collection\temppdfs\"
& dr("List_ID") & ".pdf"

xPDF.Export(rpt.Document, pdfPath)
xPDF.Dispose()
Next

I'm only able to get about 200 through before it gives me an Out of Memory
exception. Seems like there is an obvious design flaw, and I'm just not
sure how to structure this so it "reuses" memory. Any thoughts?

Thanks!
 
M

Marina Levit [MVP]

To start off, I am not at all familiar with the DataDynamics library.

It looks like for every report, you are calling the Export method twice. Is
there a reason for that?

What is 'mStream'? Some sort of stream object? How is it being instantiated?
Are you closing it?
 
J

James

Whoops, 95% sure that's for exporting it to the browser where it actually
opens the PDF. I "borrowed" the code from their site and I'm pretty sure
that line should be commented. Running a test shortly to see if that has
anything to do with it. Thanks for picking up on that!
 
J

James

Alas, no luck. I can comment out that line and all references to the
mStream object...but I'm still getting the OOM Exception =/. So, basically,
the code is the same, sans that one line you referenced.
 
M

Marina Levit [MVP]

First off, comment out all the lines of code that actuall export the
document. See if it is running the report that is the problem.

If the OOM exception goes away when you do that, then I would contact the
component provider and talk to them about it. Otherwise, the memory problem
is with running the report.
 
M

Miha Markic [MVP C#]

I would suggest you to use a memory profiler to find the cause of the
problem.
You might also check .net performance counters.
But I think it has to be something with activereports becuase a DataSet with
500+ records doesn't mean anything to memory usage.
Perhaps a reasonable solution would be to create a simple sample that repros
the issue and send it to DD support.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top