Yes, I had tried that too. I had broke the script to 10000 Records and run all the script files continuously. But it doesn't solve my problem. The same error occurs.
My client doesn't recommend third party libraries/tools. So that doesn't help me.
Any suggestions to release the memory periodically ?