You are mixing old style with newer style cursors, thiswhich may be an issue? Look. Look at the code samples in the help file given here. Note they are using the newer cursors from the da
module and are constructed within a with
statement, this ensures release of memory once out side the with
block. Restructure your code to conform to this modern best practise.