Aside from the comments about memory management techniques, I wanted to give some thoughts about the code to see if it helps.
You could look into using the
arcpy.da.SearchCursor instead of the
arcpy.SearchCursor as it will improve speed and possibly memory usage.
I am not entirely sure what the
if impLyr01 == 1: sections are doing. You assign the variables at the top of your script, but I don't see any reassignment happening. So when you're comparing the values within the cursor like that, you are going to get the result every time. I am assuming that isn't your intent. I also see a couple calls to
arcpy.RefreshActiveView() in there. You might be able to reorder your code and only call it once per iteration.
You code could use some formatting niceties done to it. For instance, when you're comparing your
text_elm.text values, you could move that into a function that returns a value. It helps readability and also debugging. Another readability thing you could use is the
Aside from those pieces above to help you sort through the code, one option you may find useful is to create the majority of your variables before going into the cursor loop. This way, you're not assigning them multiple times. You may have the problem of the garbage collector not being able to keep up with the amount of items you're creating. You may want to look into using the
del keyword to see if that helps clear up your memory.
Lastly, add a few messages to your script
arcpy.AddMessage() so you can monitor your script's progress. You could output your memory usage, too. This would be a good way to section out your code (functions work great too) with messages to let you better get a feel for what is going on, and how much memory is being used.
Other than that, you may find the Code Review Stack Exchange a better place for this question as it is not really GIS related, but it is more python related.