Wasted Shared Memory aboce 2Gb fix

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