So I tried executing a script two different ways:
1)
foreach($result_array as $arg){
exec("/usr/bin/php pathToScript firstArg $arg", $array);
echo "peak usage: " . memory_get_peak_usage() . "\n\r";
}
results:
peak usage: 5457324
peak usage: 7791212
PHP Fatal error: Allowed memory size of 33554432
2)
foreach($result_array as $arg){
curl_file_get_contents("website?query=$arg"); //just a cURL helper function
echo "peak usage: " . memory_get_peak_usage() . "\n\r";
}
results:
peak usage: 5241708
peak usage: 5241708
peak usage: 5241708
peak usage: 5241708
peak usage: 5241708
peak usage: 5241708
... you get the idea
I must be mistaken about either the way exec() uses memory, or operates. It was my impression that when the program is forked, using exec(), that the calling script's memory requirements wouldn't be effected... However, this seems to not be the case.
Can anyone shed some light on what is going on here so I know what's going on?