Thanks for the response. I’ve been working on this for a few days trying to make the script work better. I can see in the SSH that the recursive exec() calling isn’t going to work in the long term as each exec creates a new process with 15MB of memory usage, and they all run at the same time until either the script finishes or the memory becomes exhausted…
Unfortunately, the entire reason I had to break up the script into chunks is because of memory leaks in the while loops. I have quite a few scripts like this because I can’t figure out how to “clear” the memory after each loop. It just keeps accumulating even after I “unset” and “NULL” the variables used in the while loop.
The only hint that I’ve found is with using some kind of Object-Oriented programming style inside classes. Since I’ve done everything in a Procedural style, this is all kind of new to me. I’ve been trying to find a solution for this crappy memory leak problem for a few years and gave up many times. Do you know how to fix this, or to point me in the right direction?
I re-designed the script back to one large script without splitting it into chunks. It seems like it’s working MUCH better and much faster now by running it with the command: “/usr/local/php54/bin/php” . Maybe this behaves differently than running it on the web server? Seems like the memory usage isn’t accumulating like it used to.