python upgrade to 2.7.13
Just add this to the end of the function execution
for x in locals().keys(): del locals()[x] ()
The principle is that locals() lists all the current local variables and manually clears the overhead generated by the current function to free up memory.
Above this python clear function occupied memory method is all I have shared with you, I hope to give you a reference, and I hope you support me more.