IActiveView.Output slows down over time

08-30-2018 07:17 PM
New Contributor III

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, pixelBounds.top * 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...
Tags (2)
0 Kudos
2 Replies
Occasional Contributor

Jordan, have you tried refreshing either IIS and/or the application pool in which the service resides?

We have observed somewhat similar behavior with one of our sites previously and now include a server reboot as part of our monthly maintenance tasks.

Good luck, Matthew

0 Kudos
New Contributor III

Hi Matthew,

Thanks for the reply.

Yes, we have tried restarting IIS application pool and have also restarted the entire Windows Server. When its back up, it goes back to the time it was taking before we restarted.

The only way we've been able to get the times back down to < 20 seconds, is to do a complete new server build and re-deploy of everything. Even if we take a snapshot of the Window Server, when say its taking 50 seconds to print, and re-deploy the snapshot, it goes back to taking 50 seconds.



0 Kudos