facebook/hhvm — pull request #1224 by iperevozchikov (2013-10-30 06:56:25+00:00)
Title: Fixed bug #1182: preg_replace should support some sort of cache eviction

Problem
------------
If we have count of dynamic regexes more than cache capacity, hhvm raised error that "PCRE cache full".

Solution
------------
Set lock on read cross-thread regex storage, and call reinitialize storage method. Losk set via mutex.

Test
-------
hphp/test/slow/ext_preg/1182.php

```php
$subject = 'done';
for ($i = 0; $i < 97 * 1024; $i++) {
preg_replace('/(' . $i . ')/ui', 'replaced', $subject);
}

var_dump($subject);
```