AnsweredAssumed Answered

IActiveView.Output slows down over time

Question asked by JKingesriaustralia-com-au-esridist Employee on Aug 30, 2018
Latest reply on Aug 30, 2018 by JKingesriaustralia-com-au-esridist

Hi All,


We have a custom print service application written for ArcObjects .NET SDK 10.4.1. The application opens up an MXD, selects a bunch of features using Definition Queries, zooms 4 data frames to a specified extent and then does a IActiveView.Output() to export to a PDF, using IExportPDF.


// Prepare for exporting the layout to PDF

IExportPDF exportPDF = new ExportPDFClass();
IExport exporter = (IExport)exportPDF;

exportPDF.EmbedFonts = true;
exportPDF.Compressed = true;
exportPDF.ImageCompression = esriExportImageCompression.esriExportImageCompressionLZW;
((IOutputRasterSettings)exportPDF).ResampleRatio = 1;

// Compute the pixel bounds of the full layout

tagRECT pixelBounds = pageLayoutView.ExportFrame;
IEnvelope pixelBoundsEnvelope = new EnvelopeClass();
pixelBoundsEnvelope.PutCoords(pixelBounds.left * resolution / 96, * resolution / 96, pixelBounds.right * resolution / 96, pixelBounds.bottom * resolution / 96);

// Create an export file in the ArcGIS Server's output directory

String exportFileName = String.Format("_ags_{0}.pdf", _instance);
//exporter.ExportFileName = ArcGISServerConfiguration.PhysicalOutputDirectory + "\\" + exportFileName;
exporter.ExportFileName = outputDir+ "\\" + exportFileName;
exporter.Resolution = (short)resolution;
exporter.PixelBounds = pixelBoundsEnvelope;

if (_debug)
DebugMessage(String.Format("ExportPDF('{0}') {{", exportFileName));

// Render the layout to the Exporter's device context

int hDC = exporter.StartExporting();
pageLayoutView.Output(hDC, resolution, ref pixelBounds, null, null);

if (_debug)
DebugMessage(String.Format("}} ExportPDF('{0}') finished", exportFileName));
DebugMessage("Cleanup() {");


What is happening is; we set this up on an IIS server (running as an asmx service) and users hit the service to print a map. When it is first deployed, everything works nicely and maps are taking around 5-10 secs to print to PDF. Over the course of a few months, that print time starts to get slower and slower, until eventually maps are taking well over 2 minutes to print.
We've gone through a done a bunch of testing on the MXDs being used as the print templates, they all appear to work fine and the connections to the database are responsive. If I do a manual Export to PDF from the MXD itself, it takes around 5 seconds as expected.
In our debug logging, the only part of our application which is slowing down is the IActiveView.Output() method (pageLayoutView.Output() in the code above). The problem is we can't really investigate too much into what is actually happening here under the hood, I understand it is using Windows GDI, but what could be slowing this down over time? There doesn't appear to be memory issues on the server, the memory is stable over this time period.
If we destroy the server and re-create it and the service again from scratch, printing goes back to taking 5-10 seconds again.
Any ideas what might be slowing us down? Were going to try to update windows graphics drivers, but other than that, are not really sure where to look for answers...