Hi all, I'm not a developer but do have to write the odd bit of code to automate output. I have written a script which uses an mxd which has 3 data frames with different basemaps and some textual information which serves as a template to produce a pdf. I have written a script (attached) which loops through the sites of interest zooms to the extent, adjusts the scale to a set scale and then populates the textual information including two tables by doing an intersection with a point and polygon feature class. It all works ok but tends to crash out in or around the 80th site that it hits. I thought at first it was a memory leak, hence all the del()'s but when I checked it out in the resource monitor I found memory consumption was low but the thread count is incrementing by 3 or 4 every time it loops. Anybody any ideas on why this might be happening or a workaround to fix.
Thanks in advance
without looking at your code it sounds like that despite using del statements, python garbage collection isn't happening... pay attention to what happens when 3 arrays are created. a is the original, b is a copy/clone of a and c is assigned to equal a.
Everything behaves nicely until a is deleted, b's data remains unchanged, but now c's data reference has moved to that of b. so sometimes when you delete something, you have to be aware whether any 'copies' or 'references' to the originals still exist
>>> a = np.arange(5) >>> b = np.copy(a) >>> c = a >>> a.data <memory at 0x10bbe6c48> >>> b.data <memory at 0x10bbe6d08> >>> c.data <memory at 0x10bbe6c48> >>> del a >>> c.data <memory at 0x10bbe6d08>