preg_replace_callback出现内存泄露。有人解决了么?
环境:php5.4.22 +centos 5.4+nginx
--------------------------------------------------------------------------------------------------------------
下面这个问题发现的:http://bbs.csdn.net/topics/390784375
----------------------------------
同样问题:
http://bbs.csdn.net/topics/390693060
----------------------------------------------------------------------
测试代码:
<br /><?php<br />$content='<php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php> testtest';<br />$a=123;<br />$content= preg_replace_callback('/<php(\s*?)>(.*?)<\/php(\s*?)>/is', function($match) use($a){return 123;}, $content);<br />echo $content;<br />$content = preg_replace_callback('/[a-z]/', function ( $matches ) {<br /> return strtoupper($matches[0]);<br /> }, 'abdfrew');<br />echo $content;<br />$content = 'abdfrew';<br />preg_match_all('/[a-z]/', $content, $matches );<br />foreach($matches[0] as $v) $r[$v] = strtoupper($v);<br />$content = strtr($content, $r);<br />echo $content;
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号