So firstly, thanks to everyone who pointed me in the right direction regarding tracking usage of PHP and laravel.
I answered my own question, hoping that it would benefit laravel developers in the future, as my solution was hard to find.
After entering 'dmesg' to display system messages. I found that php script was killed by Linux.
So, I added memory log calls to my script before and after each of the key areas of my script:
Log::Info('Memory now at: ' . memory_get_peak_usage());
Then I ran the script, watching the log output as well as the output of the "top" command.
I found that even though my methods were ending and the variables were out of scope, the memory was not freed.
Things I tried that DIDNTs matter in my case:
- unset ($ varname) for variables after I finished with them - hoping the GC starts.
- adding gc_enable () at the beginning of the script, and then adding calls to gc_collect_cycle () after a significant amount of vars is not set.
- Disabling mysql transactions - perhaps this is memory intensity - it is not.
Now it was strange that none of the above had any meaning. My script still used 150mb or ram in time when it was killed!
Solution that really worked:
Now this is definitely a laravel specific solution. But my task is to parse a large XML feed and then insert thousands of rows into mysql using the ORKENT ORM element.
It turns out that Laravel creates information and log objects to help you see query performance.
Disabling it with the next โmagicโ call, I got my script from 150 mb to 20 MB!
This is magic"; call:
DB::connection()->disableQueryLog();
I can tell you, when I found this call, I grabbed at a straw; - (