Select to view content in your preferred language

Method for clearing Python Window in ArcMap programmatically

8281
12
10-19-2018 06:26 AM
DarrenSmith
Regular Contributor

Is there a way of clearing (flushing) the Python Window in ArcMap from Python (that works in 10.2.1)?

0 Kudos
12 Replies
LukeWebb
Frequent Contributor

The issue is if I write in the python window:      

data = []

for row in some_fc:

     data.append(row stuff)

I now have this in memory,. Clearing the screen is good, but I can still do :

print data

to get back my stuff, so memory is used. How to release this?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Just del data, garbage collection will shortly reclaim the memory.

0 Kudos
DanPatterson_Retired
MVP Emeritus

you seem to have missed del

https://community.esri.com/message/807449-re-method-for-clearing-python-window-in-arcmap-programmati... 

and if you want to track and otherwise play with the garbage, look at the gc module

import gc
dir(gc)['DEBUG_COLLECTABLE', 'DEBUG_LEAK', 'DEBUG_SAVEALL', 'DEBUG_STATS',
 'DEBUG_UNCOLLECTABLE', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 
'callbacks', 'collect', 'disable', 'enable', 'garbage', 'get_count', 'get_debug', 
'get_objects', 'get_referents', 'get_referrers', 'get_stats', 'get_threshold',
 'is_tracked', 'isenabled', 'set_debug', 'set_threshold']‍‍‍‍
0 Kudos