go to bug id or search bugs for
I am using a script retrieving distant content to local system using OAuth fetch function, thus copying the whole files into memory, before writing them to disk using file_put_contents.
That means potentially big files end up in RAM.
My script hangs up in the middle of the loop with a strange and important error:
'NOTICE: PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 51366915 bytes)'.
None of my files exceed thos 128MiB, by far.
Using a loop to iterate through files, I started sending to stderr custom error messages to track PHP memory usage and eventually track down any memory leak.
Using (in that specific order) the functions memory_get_usage(), memory_get_usage(true), memory_get_peak_usage() and memory_get_peak_usage(true), I got the following log (sample):
NOTICE: PHP message: 18044352 (18350080) of 31360096 (32505856)
I noticed the values returned by the peak_usage procedures were always the same, equal to 31MiB.
Why is the max possible allocated memory for my script set to 31 MiB?
The 'memory_limit' from PHP Info says 128M, confimed by the fatal error message.
Add a Patch
Add a Pull Request
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.