opcache used_memory reports negative value
<?php
var_dump(opcache_get_status()['memory_usage']);
?>
Reports a negative value for used_memory.
Image is from a VDS system with opcache.memory_consumption=1GB and several sites.
But issue was reproduced within the following environment:
- PHP 8.3
- shared hosting server with PHP-FPM
- two sites with individual opcache.memory_consumption settings
- first site: 128M
- second site: 256M
- global settings in plesk: 256M
Second site reports correct values, but first site, with lower settings reports negative value for "used_memory"
Changing both sites to dedicated PHP-FPM fixes the issue, but in the default config it fails.
C.
You probably meant to submit this as bug report, not as documentation issue. Transferring.
I'm seeing similar values on 8.5 (FrankenPHP) and a few more broken ones.
Also, opcache_get_configuration reports 0 for "opcache.memory_consumption", but that value should be 256MB (and according to ini_get_all is).
`opcache_get_status();`
array (
'opcache_enabled' => true,
'cache_full' => false,
'restart_pending' => false,
'restart_in_progress' => false,
'memory_usage' =>
array (
'used_memory' => -219550752,
'free_memory' => 218927256,
'wasted_memory' => 623496,
'current_wasted_percentage' => INF,
),
'interned_strings_usage' =>
array (
'buffer_size' => 16777216,
'used_memory' => 10241152,
'free_memory' => 6536064,
'number_of_strings' => 76914,
),
'opcache_statistics' =>
array (
'num_cached_scripts' => 1365,
'num_cached_keys' => 1993,
'max_cached_keys' => 32531,
'hits' => 20153,
'start_time' => 1769432071,
'last_restart_time' => 0,
'oom_restarts' => 0,
'hash_restarts' => 0,
'manual_restarts' => 0,
'misses' => 1381,
'blacklist_misses' => 0,
'blacklist_miss_ratio' => 0.0,
'opcache_hit_rate' => 93.58688585492709,
),
'scripts' =>
array (
...
),
'jit' =>
array (
'enabled' => false,
'on' => false,
'kind' => 0,
'opt_level' => 0,
'opt_flags' => 0,
'buffer_size' => 0,
'buffer_free' => 0,
),
)
`opcache_get_configuration();`
array (
'directives' =>
array (
'opcache.enable' => true,
'opcache.enable_cli' => false,
'opcache.use_cwd' => true,
'opcache.validate_timestamps' => true,
'opcache.validate_permission' => false,
'opcache.validate_root' => false,
'opcache.dups_fix' => false,
'opcache.revalidate_path' => false,
'opcache.log_verbosity_level' => 1,
'opcache.memory_consumption' => 0,
'opcache.interned_strings_buffer' => 16,
'opcache.max_accelerated_files' => 32531,
'opcache.max_wasted_percentage' => 0.05,
'opcache.force_restart_timeout' => 180,
'opcache.revalidate_freq' => 2,
'opcache.preferred_memory_model' => '',
'opcache.blacklist_filename' => '',
'opcache.max_file_size' => 0,
'opcache.error_log' => '',
'opcache.protect_memory' => false,
'opcache.save_comments' => true,
'opcache.record_warnings' => false,
'opcache.enable_file_override' => true,
'opcache.optimization_level' => 0,
'opcache.lockfile_path' => '/tmp',
'opcache.file_cache' => '',
'opcache.file_cache_read_only' => false,
'opcache.file_cache_only' => false,
'opcache.file_cache_consistency_checks' => true,
'opcache.file_update_protection' => 2,
'opcache.opt_debug_level' => 0,
'opcache.restrict_api' => '',
'opcache.huge_code_pages' => false,
'opcache.preload' => '',
'opcache.preload_user' => '',
'opcache.jit' => 'disable',
'opcache.jit_buffer_size' => 67108864,
'opcache.jit_debug' => 0,
'opcache.jit_bisect_limit' => 0,
'opcache.jit_blacklist_root_trace' => 16,
'opcache.jit_blacklist_side_trace' => 8,
'opcache.jit_hot_func' => 127,
'opcache.jit_hot_loop' => 61,
'opcache.jit_hot_return' => 8,
'opcache.jit_hot_side_exit' => 8,
'opcache.jit_max_exit_counters' => 8192,
'opcache.jit_max_loop_unrolls' => 8,
'opcache.jit_max_polymorphic_calls' => 2,
'opcache.jit_max_recursive_calls' => 2,
'opcache.jit_max_recursive_returns' => 2,
'opcache.jit_max_root_traces' => 1024,
'opcache.jit_max_side_traces' => 128,
'opcache.jit_prof_threshold' => 0.005,
'opcache.jit_max_trace_length' => 1024,
),
'version' =>
array (
'version' => '8.5.2',
'opcache_product_name' => 'Zend OPcache',
),
'blacklist' =>
array (
),
)
I have the same issue with FrankenPHP v1.11.3 PHP 8.5.4 on debian trixie. and that make some app to crash because of DivisionByZeroError
Just wanted to add a +1. We are using PHP with a custom SAPI integration in ZTS. It happens on Windows and Linux.
I'm going to say that this is fixed now (commits a2d8ee27f2b and 4eac7a399a0), but if you still see this problem in 8.5.13, please raise a new GH issue. This is unlikely to be backported to PHP 8.4.