<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Looping mxd's and clearing memory in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/looping-mxd-s-and-clearing-memory/m-p/119046#M9374</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are having memory issue you need to make your metafile as SMALL as possible, not bigger. It could also be an issue with your printer running out of memory, even with a print server we noticed this on our plotters. This is exacerbated when using high DPI outputs. Try running the script without the pdf export, or vice versa, and see if you still get the issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Sep 2011 20:39:53 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2011-09-07T20:39:53Z</dc:date>
    <item>
      <title>Looping mxd's and clearing memory</title>
      <link>https://community.esri.com/t5/python-questions/looping-mxd-s-and-clearing-memory/m-p/119045#M9373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey people,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to run a script for some batch printing and pdf'ing. I am running it against a directory with 3 mxd's in it. My script runs through fine, but as each mxd prints, they progressively start missing data. i.e the first mxd prints fine, the second one starts to lose some of the data in the map (portions of dataframe, text elements, legends, etc) and the third mxd prints almost nothing. I have a feeling it's a memory issue, but I'm unsure where to clear memory in the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attempted to increase my metafile memory allocation to as high as it goes (200 mb), but that hasn't helped either. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import sys, arcpy, traceback
import os
import glob

# Location of exported pdf's
exportpdf = r"Z:\ESRI\Figure_Sourcing\Figures\PDF\Export_Test\\"

# Provide folder path to loop through (first level only)
folderPath = r"Z:\ESRI\Figure_Sourcing\Figures\TestFigs\Test_Print"


for filename in glob.glob(os.path.join(folderPath, "*.mxd")):

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fullpath = os.path.join(folderPath, filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.PrintMap(mxd, r"\\chip\Xerox 7655 (Upstairs)")
##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd
##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filename
##&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fullpath

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.isfile(fullpath):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basename, filename2 = os.path.split(fullpath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print basename
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print filename2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shortname, extension = os.path.splitext(filename2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shortname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, exportpdf + shortname, "PAGE_LAYOUT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del shortname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del basename
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filename2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filename
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del extension
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 19:06:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-mxd-s-and-clearing-memory/m-p/119045#M9373</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2011-09-07T19:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Looping mxd's and clearing memory</title>
      <link>https://community.esri.com/t5/python-questions/looping-mxd-s-and-clearing-memory/m-p/119046#M9374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are having memory issue you need to make your metafile as SMALL as possible, not bigger. It could also be an issue with your printer running out of memory, even with a print server we noticed this on our plotters. This is exacerbated when using high DPI outputs. Try running the script without the pdf export, or vice versa, and see if you still get the issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 20:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-mxd-s-and-clearing-memory/m-p/119046#M9374</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-09-07T20:39:53Z</dc:date>
    </item>
  </channel>
</rss>

