I have developed an application where I generate a lot of PDF files with Crystal Report and then send them by email. The problem is that as I generate the PDFs the consumption of RAM increases steadily until a System.OutOfMemoryException error is thrown. I have already put the lines of code to supposedly release the resources (Dispose and Close) I have even tried directly invoking GC.Collect () but I can not solve this problem. The code fragment where I generate the PDFs is the following:
ReportDocument rd = new ReportDocument();
string direccion = path + "/Reportes";
rd.Load(Path.Combine(direccion, "FAC.rpt"));
rd.Database.Tables[0].SetDataSource(listaFac);
rd.Database.Tables[1].SetDataSource(listaDet);
rd.Subreports[0].SetDataSource(listaFormPag);
rd.SetParameterValue("@texto_inferior_rides", e.texto_inferior_rides);
rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path + "/Archivos/PDF/" + d.claveAcceso + ".pdf");
rd.Close();
rd.Dispose();
I appreciate any help or suggestion.
Greetings.