Posted 29 November 2020, 7:41 pm EST
I implemented a paralell foreach and I always get the following error message:
The size of the bitmap is too large that there is not enough memory in system can be allocated to the bitmap.
I generate 200 and more Reports and will export in tiff files
and would like to be as efficient as possible with the Tiff export.
Here is the complete error message:
Cannot create the tiff document. Name: ActiveReports Document;System.Exception*Void CommonExport(GrapeCity.ActiveReports.Document.SectionDocument, System.String, System.IO.Stream)The size of the bitmap is too large that there is not enough memory in system can be allocated to the bitmap. bei GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport.CommonExport(SectionDocument document, String pageRange, Stream outputStream)
I use the version 14.1.20320
The problem is the parallel.Foreach →
Developer envirorment:
I must limited the MaxDegreeOfParallelism to 3, because it’s higher then 3 then it throws exception in marked code line!
Customer envirorment:
MaxDegreeOfParallelism = 3 does not fix the problem. The customer continues to receive the same error message.
public static void ArchiveTiffFiles(IList<PrintDocuments> allReports, string tiffFilePath) // in allReports are 200 Reports --> one generated TiffFile is 33.1 MB in size
{
var resultReportlst = allReports.Where(re => re.IndexValue != null).GroupBy(report => report.OrderCounter).OrderBy(rp => rp.Key);
Parallel.ForEach(resultReportlst, new ParallelOptions { MaxDegreeOfParallelism = 4 }, report =>
{
foreach (var exportDocumentPage in report.Document.Document.Pages)
{
var tmpSectiondocument = new SectionDocument();
tmpSectiondocument.Pages.Add(exportDocumentPage);
if (report.Document.Document.Pages.Count > 1)
{
fileCount = documentPageCounter++;
}
else
{
fileCount += documentPageCounter++;
}
string tifffilenumber = fileCount.ToString("D3");
GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport tiffSetting = new GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport();
tiffSetting.CompressionScheme = CompressionScheme.None;
tiffSetting.Dither = true;
tiffSetting.DpiX = 300;
tiffSetting.DpiY = 300;
tiffSetting.Pagination = true;
tiffSetting.Export(tmpSectiondocument, Path.Combine(tiffFilePath, tifffilenumber) + ".tif"); // Here throws the exception with the message: The size of the bitmap is too large that there is not enough memory in system can be used to draw the report on the bitmap.
tiffSetting.Dispose();
}
});
}
How can I fix this problem? I dispose of the export settings…
Regards,
Ramona