php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69885 (unexpecteadly) Increasing wasted memory when file are removed
Submitted: 2015-06-19 15:13 UTC Modified: 2021-07-08 11:28 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:0 (0.0%)
From: maxence at typhon dot com Assigned: cmb (profile)
Status: Duplicate Package: opcache
PHP Version: 5.6.10 OS: Debian 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: maxence at typhon dot com
New email:
PHP Version: OS:

 

 [2015-06-19 15:13 UTC] maxence at typhon dot com
Description:
------------
PHP 5.6.10 from tarbal, compiled with :

./configure --disable-all --prefix=/usr/local/php-5.6.10 --enable-fpm --enable-ctype --enable-mbstring --enable-gd-native-ttf --enable-zip --with-mcrypt --with-openssl --with-gd --with-jpeg-dir=/usr/lib --with-freetype-dir --with-curl --with-pcre-regex --with-gettext --enable-pdo --with-pdo-mysql=mysqlnd --with-iconv --enable-fileinfo --enable-filter --enable-json --enable-session --enable-hash --enable-libxml --enable-dom --enable-libxml --enable-simplexml --enable-bcmath --enable-soap --enable-opcache --enable-ftp --enable-intl

opcache config is :

opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 16 => 16
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 4 => 4
opcache.max_accelerated_files => 30000 => 30000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 1024 => 1024
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On

We used to remove a lot of php files from time to time (~ 70Mb) when releasing, without any manual opcache flush or php restart. Every time we remove the files, the same amount of space is added to wasted_memory. Looks like opcache does not reclaim the memory when the file is removed (and then recreated) but only put it as "wasted". Also, the memory wasted is far bigger than the configured 5%, and opcache doesn't restart.

I achieved to reproduce this in a simple test (see below). Note that the sleep time matters. With "sleep 3", the wasted memory increase after every cycle. With "sleep 2", it only increases every ~ 2 times, which let me think the issue has something to do with the revalidate process (and revalidate_freq).




Test script:
---------------
 # for i in $(seq 1 100);do rm -f /var/www/web-default/a.php && echo '<? echo("hi"); ?>' > /var/www/web-default/a.php; sleep 3; curl -s http://127.0.0.1/a.php >/dev/null; curl -s http://127.0.0.1/opcache_stat.php |grep wasted_memory;done
       

Expected result:
----------------
wasted memory should not increase, so something like :

 "wasted_memory": 72192,
 "wasted_memory": 72192,
 "wasted_memory": 72192,
 "wasted_memory": 72192,

Actual result:
--------------
wasted memory increase for the same size every time.

"wasted_memory": 72192,
"wasted_memory": 72960,
"wasted_memory": 73728,
"wasted_memory": 74496,
"wasted_memory": 75264

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-08 11:28 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-07-08 11:28 UTC] cmb@php.net
Duplicate of bug #68631.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC