<?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 Use Subprocess to Alleviate Memory Usage Issues in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294059#M22740</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To All Python Users:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script that is updating mxds and then saving them.&amp;nbsp; After saving the mxd I am deleting the mxd object, but memory usage keeps increasing until the python script just hangs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have read that I can use a subprocess to fix this problem, but I am unsure of the syntax to use.&amp;nbsp; I will be drilling down through a directory and all of its subdirectories for mxd files (This will be my main python script).&amp;nbsp; Once I have an mxd file as the focus, I want to use a subprocess to start another python script that will open the mxd, replace data sources, save the mxd and then delete the mxd object from memory.&amp;nbsp; Then I will return to the main script to get another file which should free up memory as the subprocess has terminated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know the syntax I would use to call the secondary python script with an argument being the mxd file that has the focus?&amp;nbsp; Any help or hints are greatly appreciated.&amp;nbsp; Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Feb 2012 12:40:31 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2012-02-07T12:40:31Z</dc:date>
    <item>
      <title>Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294059#M22740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To All Python Users:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script that is updating mxds and then saving them.&amp;nbsp; After saving the mxd I am deleting the mxd object, but memory usage keeps increasing until the python script just hangs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have read that I can use a subprocess to fix this problem, but I am unsure of the syntax to use.&amp;nbsp; I will be drilling down through a directory and all of its subdirectories for mxd files (This will be my main python script).&amp;nbsp; Once I have an mxd file as the focus, I want to use a subprocess to start another python script that will open the mxd, replace data sources, save the mxd and then delete the mxd object from memory.&amp;nbsp; Then I will return to the main script to get another file which should free up memory as the subprocess has terminated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know the syntax I would use to call the secondary python script with an argument being the mxd file that has the focus?&amp;nbsp; Any help or hints are greatly appreciated.&amp;nbsp; Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 12:40:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294059#M22740</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-07T12:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294060#M22741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; 
import subprocess

procs = []

cmd = "python foo.py arg1 arg2"
proc = subprocess.Popen(cmd,shell=True)
procs.append(proc)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you will probably want to keep track of the number of running processes and limit how many are run at once.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; 
def numRunningProcs(procs):
&amp;nbsp;&amp;nbsp;&amp;nbsp; numProcs = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for proc in procs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc.poll()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if proc.returncode == None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; numProcs = numProcs + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return numProcs
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:08:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294060#M22741</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2021-12-11T14:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294061#M22742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried running the first portion of your code, but the subprocess is not executing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my syntax to call the subprocess script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cmd = "C:\\Python26\\ArcGIS10.0\\python.exe \\\\tgapparc01\\c$\\GIS Testing\\ReplaceSource.py full_path"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the cmd line, full_path is the file that has the focus.&amp;nbsp; File is stored in the full_path variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the ReplaceSource.py script, I am trying to use the arcpy.GetParameterAsText(0) to bring in this argument.&amp;nbsp; I'm not sure if this is the problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could this issue possibly be how I am calling out the python executable and the python script that gets run in the subprocess?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your assistance is greatly appreciated.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 16:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294061#M22742</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-07T16:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294062#M22743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Chris:&lt;BR /&gt;&lt;BR /&gt;I tried running the first portion of your code, but the subprocess is not executing.&lt;BR /&gt;&lt;BR /&gt;Here is my syntax to call the subprocess script:&lt;BR /&gt;&lt;BR /&gt;cmd = "C:\\Python26\\ArcGIS10.0\\python.exe \\\\tgapparc01\\c$\\GIS Testing\\ReplaceSource.py full_path"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In the cmd line, full_path is the file that has the focus.&amp;nbsp; File is stored in the full_path variable.&lt;BR /&gt;&lt;BR /&gt;In the ReplaceSource.py script, I am trying to use the arcpy.GetParameterAsText(0) to bring in this argument.&amp;nbsp; I'm not sure if this is the problem?&lt;BR /&gt;&lt;BR /&gt;Could this issue possibly be how I am calling out the python executable and the python script that gets run in the subprocess?&lt;BR /&gt;&lt;BR /&gt;Your assistance is greatly appreciated.&amp;nbsp; Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe the problem is with your command string.&amp;nbsp; The space in the path to the python script causes it to be treated as two arguments. So python.exe only gets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"\\\\tgapparc01\\c$\\GIS" as the script argument.&amp;nbsp; If you cannot change the directory name, then you might try putting the full path to the python script in single quotes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 17:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294062#M22743</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-07T17:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294063#M22744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you please be a little bit more specific in what your code is looking for with the cmd = "python foo.py arg1 arg2" line?&amp;nbsp; I still cannot get my code to evaluate the subprocess python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does python refer to python.exe that has been installed on the computer that you are running this script from (e.g. c:\Python26\ArcGIS10.0\python.exe)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does foo.py refer tp the python script that you are running in the subprocess?&amp;nbsp; If so, wouldn't you need to specify the full path to this file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are arg1 and arg2 variables from the primary script that you are sending to the subprocess script?&amp;nbsp; If so, what is the syntax to get the subprocess script to accept these arguments?&amp;nbsp; I ask because I am using arcpy.GetParameterAsText(0) to evaluate the single argument that I am trying to pass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your assistance is greatly appreciated.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:03:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294063#M22744</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-07T18:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294064#M22745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;not sure if you saw my last response...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294064#M22745</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-07T18:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294065#M22746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did see your last response and I moved the python script, that is called, to a folder with no spaces.&amp;nbsp; No matter how I format the cmd line, the subprocess never gets executed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294065#M22746</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-07T18:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294066#M22747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Chris:&lt;BR /&gt;&lt;BR /&gt;Can you please be a little bit more specific in what your code is looking for with the cmd = "python foo.py arg1 arg2" line?&amp;nbsp; I still cannot get my code to evaluate the subprocess python script.&lt;BR /&gt;&lt;BR /&gt;Does python refer to python.exe that has been installed on the computer that you are running this script from (e.g. c:\Python26\ArcGIS10.0\python.exe)?&lt;BR /&gt;&lt;BR /&gt;Does foo.py refer tp the python script that you are running in the subprocess?&amp;nbsp; If so, wouldn't you need to specify the full path to this file?&lt;BR /&gt;&lt;BR /&gt;Are arg1 and arg2 variables from the primary script that you are sending to the subprocess script?&amp;nbsp; If so, what is the syntax to get the subprocess script to accept these arguments?&amp;nbsp; I ask because I am using arcpy.GetParameterAsText(0) to evaluate the single argument that I am trying to pass.&lt;BR /&gt;&lt;BR /&gt;Your assistance is greatly appreciated.&amp;nbsp; Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. python refers to python.exe. if it is not in the system path, then use the full path to python.exe&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. foo.py is the python script to run in subprocess.&amp;nbsp; use the full path.&amp;nbsp; there cannot be spaces in the path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. arg1,arg2 are arguements to the subprocess script. use arcpy.GetParameterAsText(0) as usual.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:29:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294066#M22747</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-07T18:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294067#M22748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Chris:&lt;BR /&gt;&lt;BR /&gt;I did see your last response and I moved the python script, that is called, to a folder with no spaces.&amp;nbsp; No matter how I format the cmd line, the subprocess never gets executed.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;can you post the code in which you are making the subprocess call.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294067#M22748</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-07T18:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294068#M22749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the code I am trying to run to call a subprocess to actually modify properties of mxd files:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, sys, string, arcpy
import subprocess

mxd_match = ".mxd"
fileErrList = []
procs = []

Directory_Search = r"\\tgapparc00\e$\restore5\Planning_Run\Broken_Links\Test"

for root, dirs, files in os.walk(Directory_Search):

&amp;nbsp;&amp;nbsp;&amp;nbsp; fListLength = len(files)

&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fListLength != 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in files:

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.endswith(mxd_match):

&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;&amp;nbsp; full_path = root + "\\" + str(f)
&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;&amp;nbsp; cmd = "'C:\Python26\ArcGIS10.0\python.exe \\\\tgapparc01\\c$\\ReplaceSource.py' full_path"

&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc = subprocess.Popen(cmd,shell=True)
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; procs.append(proc)

 &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294068#M22749</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-12-11T14:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294069#M22750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It seems that the syntax I was using only works on linux, not windows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for windows,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cmd = [r"C:\Python26\ArcGIS10.0\python.exe", r"\\tgapparc01\c$\ReplaceSource.py", full_path]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc = subprocess.Popen(cmd)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 19:13:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294069#M22750</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-07T19:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294070#M22751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Chris&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That was the syntax that was needed to call the subprocess python script in Windows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could not find any other examples of that syntax when searching the web.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 19:33:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294070#M22751</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-07T19:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294071#M22752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;as an alternative to subprocess.Popen, you might consider using the multiprocessing.Pool class.&amp;nbsp; With Popen you will need to manage the number of processes that are running at once.&amp;nbsp; With Pool you can define the number of worker processes in the Pool (#cores/processors -1) and it will keep that number of worker processes running.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 19:44:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294071#M22752</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-07T19:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294072#M22753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why do I need to worry about the number of subprocesses?&amp;nbsp; I wrote my main python script to loop through a directory, its subdirectories and files looking for mxds.&amp;nbsp; Then I call the subprocess python script for the file that has focus and I manipulate that mxd.&amp;nbsp; Once that is done and the mxd gets saved, I thought the code goes back to the main python script and releases the subprocess python script from memory.&amp;nbsp; Then I loop to the next mxd and call the subprocess python script again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason I went this route in the first place was due to memory usage always climbing while looping through a directory until the python script just hung.&amp;nbsp; Could it be that I just needed to release additional items from temporary memory when I was just using one script to obtain the results?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 21:26:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294072#M22753</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-07T21:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294073#M22754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Chris:&lt;BR /&gt;&lt;BR /&gt;Why do I need to worry about the number of subprocesses?&amp;nbsp; I wrote my main python script to loop through a directory, its subdirectories and files looking for mxds.&amp;nbsp; Then I call the subprocess python script for the file that has focus and I manipulate that mxd.&amp;nbsp; Once that is done and the mxd gets saved, I thought the code goes back to the main python script and releases the subprocess python script from memory.&amp;nbsp; Then I loop to the next mxd and call the subprocess python script again.&lt;BR /&gt;&lt;BR /&gt;The reason I went this route in the first place was due to memory usage always climbing while looping through a directory until the python script just hung.&amp;nbsp; Could it be that I just needed to release additional items from temporary memory when I was just using one script to obtain the results?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to worry about the number of processes because the script that fires off Popen does not wait for Popen to finsh.&amp;nbsp; Therefore you will likely end up with many processes running concurrently (more than the number of cores/processors), saturating the cpu and causing the machine to thrash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's possible that your original script is written in a manner that is causing the high memory usage because temp data is not released for garbage collection.&amp;nbsp; Post the script if you like and i'll take a look.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2012 16:13:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294073#M22754</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2012-02-08T16:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294074#M22755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Chris.&amp;nbsp; The script with the subprocess did exactly what you said it would and flooded the processor with parallel processes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code with just one python script where the memory usage keeps increasing until the python scripts freezes up.&amp;nbsp; The script is meant to loop through a selected directory, get the mxds and resource the SDE layers from the original SDE connection to a different SDE connection.&amp;nbsp; You can open up Task Manager while running this script and see how memory usage for the pythonw.exe process keeps increasing.&amp;nbsp; Please note that you will need to run this script on a directory with a good number of mxd files that have many SDE layers in order to see the performance hit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, sys, string, arcpy

mxd_match = ".mxd"

Directory_Search = r"\\server00\e$\restore5\Experiment\Test_10"
new_connPrefix = r"C:\Documents and Settings\Application Data\ESRI\Desktop10.0\ArcCatalog"

def Conn_Info(usr):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if usr == "user01":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_connection = new_connPrefix + "\\" + usr + "_dir_conn@production.sde"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new_connection
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif usr == "user02":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_connection = new_connPrefix + "\\" + usr + "_dir_conn@development.sde"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new_connection
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif usr == "user03":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_connection = new_connPrefix + "\\" + usr + "_dir_conn@production.sde"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new_connection
&amp;nbsp;&amp;nbsp;&amp;nbsp; del new_connection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
for root, dirs, files in os.walk(Directory_Search):
# for root, dirs, files in os.walk(arcpy.GetParameterAsText(0)):

&amp;nbsp;&amp;nbsp;&amp;nbsp; fListLength = len(files)

&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fListLength != 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in files:

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; full_path = root + "\\" + str(f)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.endswith(mxd_match):
&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;&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;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(full_path)

&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;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd):
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):
&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("SERVICEPROPERTIES"):
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; servProp = lyr.serviceProperties
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; user = str(servProp.get('UserName', 'N/A'))
&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;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_conn = Conn_Info(user)
&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;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(new_conn, "SDE_WORKSPACE", lyr.datasetName)


&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del lyr
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&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;&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.saveACopy(root + "\\" + f[:-4] + "_New.mxd", "9.3")
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)

&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del full_path
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all your help!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:08:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294074#M22755</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-12-11T14:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294075#M22756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the only thing suspect i can see is the arcpy.mapping.ListLayers(mxd) value that might not get released. maybe try setting it to a variable and then deleting the variable when done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if f.endswith(mxd_match):
&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;&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;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(full_path)
&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;&amp;nbsp; lyrs = arcpy.mapping.ListLayers(mxd)
&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;&amp;nbsp; for lyr in lyrs:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&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;&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;&amp;nbsp;&amp;nbsp; del lyrs
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:08:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294075#M22756</guid>
      <dc:creator>ChrisFrost</dc:creator>
      <dc:date>2021-12-11T14:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Use Subprocess to Alleviate Memory Usage Issues</title>
      <link>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294076#M22757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried your approach to set lyrs equal to a variable and then delete the lyrs variable after using it in each mxd, but it did not help the memory issue.&amp;nbsp; I also tried to delete the servProp variable and that did not help the memory issue either.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2012 18:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-subprocess-to-alleviate-memory-usage-issues/m-p/294076#M22757</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-02-08T18:22:32Z</dc:date>
    </item>
  </channel>
</rss>

