Using htop to look how it EATS memory, once caught him eating 20GB RAM
What's that exactly? At least htop shows 3 "kinds" of memory: VIRT, RES, SHR. VIRT can be 20GB. But that does not mean the use 20GB of physical
memory_get_usage will show the current
memory consumption. Better to look at memory_get_peak_usage(true). And at the end of the script.