Bug #64983 [Opn->Fbk]: Memory allocated to script doesn't reflect memory_limit configuration setting

From: Date: Fri, 05 Jun 2015 01:52:17 +0000
Subject: Bug #64983 [Opn->Fbk]: Memory allocated to script doesn't reflect memory_limit configuration setting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193129@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64983&edit=1 ID: 64983 Updated by: cmb@php.net Reported by: reallfqq-php at yahoo dot fr Summary: Memory allocated to script doesn't reflect memory_limit configuration setting -Status: Open +Status: Feedback Type: Bug Package: FPM related Operating System: Debian 7 Wheezy PHP Version: 5.4.16 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2013-06-07 04:59:38] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64983&edit=1

« previous php.bugs (#193129) next »