php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64983 Memory allocated to script doesn't reflect memory_limit configuration setting
Submitted: 2013-06-07 04:59 UTC Modified: 2015-06-14 04:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: reallfqq-php at yahoo dot fr Assigned: cmb (profile)
Status: No Feedback Package: FPM related
PHP Version: 5.4.16 OS: Debian 7 Wheezy
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: reallfqq-php at yahoo dot fr
New email:
PHP Version: OS:

 

 [2013-06-07 04:59 UTC] reallfqq-php at yahoo dot fr
Description:
------------
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-05 01:52 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2015-06-05 01:52 UTC] cmb@php.net
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.


 [2015-06-14 04:22 UTC] php-bugs at lists dot php dot net
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.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC