Look this is no " copy and pasted code fixing service" , you need to to try to understand what your code does.
Cheers Rolf
PS: Je suis Charlie!
In reply to Re^3: Out of memory by LanX in thread Out of memory by wrkrbeee