title: Memory leak with preg_replace
body: <p>I'm using the <code>preg_replace</code> function to replace accents in a string, I'm working with UTF-8.</p>
  
  <p>I have incurred in what seems to be a memory leak, but I can't isolate the root cause, my code is rather simple:</p>
  
  <pre><code>    preg_replace(
          array_keys($aToNoAccents),
          array_values($aToNoAccents),
          $sText
      );
  </code></pre>
  
  <p>where <code>$aToNoAccents</code> is an associative array with entries like <code>'~[Ą]~u' =&gt; 'A', '~[Ć]~u' =&gt; 'C',</code>.
  My script prints this error for the above line:</p>
  
  <pre><code>Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 3039 bytes)
  </code></pre>
  
  <p>Obviously it's not a matter of increasing the allowed memory for PHP, (a 1Gb footprint is way off the scale of my application). Also, that line is executed thousands of times without problems but, just for some cases which are difficult to reproduce, it yields the error.</p>
  
  <p>Is anyone aware of memory problems with preg_replace and UTF-8 strings?
  Am I to use special care in passing actual parameters to such function?</p>
  
  <p>I'm using PHP 5.2.6-3 with Suhosin-Patch</p>