I have a python toolbox (.pyt) that use "SelectLayerByLocation" inside a loop that is called about 50,000 times. It grabs more and more memory after each call to "SelectLayerByLocation". It starts out processing very quickly but then slows down after about 2 hours of processing. The leak can be plugged by removing the code for the "SelectLayerByLocation" but of course that's not very useful.When I run the same code outside of ARCMAP and without the toolbox then the program does not leak memory at all. It completes all of the calls to "SelectLayerByLocation" within a reasonable amount of time. Is there any way to plug this leak? I would rather use toolbox so that I don't have to write a custom GUI.arcpy.SelectLayerByLocation_management(inlayer, "INTERSECT", pointGeo, SearchDistance)
Using ArcMap 10.1 SP1 (Build 3143)