Clearing "Current Session" Results Window using ArcPy

905
1
01-05-2018 08:03 AM
NemanjaRadakovic
New Contributor

I wrote a script in for ArcMap 10.1 using ArcPy. The script loops through different buffer lengths and matches a number of points to a number of lines. As an example, I create a 5 metre buffer around all the points and then match the points to certain lines, then I would do this with a 10 metre buffer, then a 15 metre buffer, a 20 metre buffer, etc. My memory continuously grows from one run through the loop to the next, even though after I analyze each buffer area I delete all the temporary layers and clean any lists I had stored in memory. After doing about 3 buffer areas I reach the 3 GB memory limit, and my script crashes.

 

After doing some digging I realized that my memory continuously grows because ArcMap writes out the results of every calculation to the “Results Window”.  Since I am doing thousands of calculations, this fills up fairly quickly. Once I stop my script and manually delete the “Current Session” log I regain majority of my computer’s memory. My question is, how can I delete the “Current Session” logs using Arcpy? I would like to be able to delete the “Current Session” log after each run through the loop without having to do it manually. This would allow me to free up my computer’s memory.

 

Note: I tried using “arcpy.SetLogHistory(False)” to no avail.

0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

background geoprocessing activated? if you are running the scripts within arcmap

try disabling history logging at the application level

http://desktop.arcgis.com/en/arcmap/latest/analyze/executing-tools/history-log-files.htm

use Pro is also an option.

make sure that you reuse variable names if possible

More importantly, since you are doing lots of calculations, ... batch your processes so that garbage collection and cleanup gets done.

ArcGIS Pro (and its python 3.x) can use more memory so switch over if possible

0 Kudos