Wasted Shared Memory aboce 2Gb fix #945
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I set opcache.memory_consumption to 10240 (10Gb), it is possible to have more than 2Gb of wasted memory.
The Wasted memory variable in code is stored in signed int instead of size_t.
In fact I end up with negative value of wasted memory and wasted memory percentage, which is less than default 5% for scheduling the reload.
To replicate the problem set the opcache.memory_consumption to high value (3Gb)
Use opcache_compile_file and opcache_invalidate in loop with the same file until wasted memory rises above 2Gb
php.ini settings:
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=10240
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=1048793
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=0
opcache.revalidate_freq=2
opcache.revalidate_path=1
opcache.save_comments=1
opcache.load_comments=1
opcache.error_log=/var/log/php-fpm.opcache.log
opcache.log_verbosity_level=1