Well I have been searching through the docs and through the forums and haven't really found a clear answer on PHP's Memory usage.
In PHP3 I did not have this problem but in PHP4 whenever I need to cache a file in infinate size to the disk (the file is not of infinate size, because I only use and discard the data as needed) eventually PHP4 Errors out with a Fatal Error claiming I have used up all my memory.
So here is my question.
If I did
<snip>
<?PHP
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30);
fputs($fp,"GET / HTTP/1.0\r\n");
while (.....) {
$buffer = fread($fp, 10000);
... some code to do whatever I want with the data referenced by $buffer ...
unset($buffer); /all done with data in buffer, get more data/
}
fclose($fp);
?>
</snip>
How can I remove from memory the data that I used in buffer, it seems as though PHP caches the entire file as it comes down, into memory, why would anyone need this? And why isn't it there some sort of clear method to say, I don't need that junk anymore. Note: that the variable (reference) $buffer has been unset and reused so I am pretty sure that the problem lies in the fsockopen call, as an experiment I counted all the bytes until I reached my memory limit and then made and if statement that closed the socket and reopened it to start the data stream all over again, however this is a very unpredictable way to do this when simple trashing the data in the memory would fix this problem much more efficiently and not use 8MB of memory in the process.
As I said PHP3 handled this fine before.
Thanks,
Jay