Date: 08/17/00
- Next message: Bug Database: "[PHP-DEV] PHP 4.0 Bug #5647 Updated: Compile failure"
- Previous message: Anantha Prasad/NE/USDAFS: "[PHP-DEV] Re: PHP 4.0 Bug #5647 Updated: Compile failure"
- Next in thread: Andrei Zmievski: "Re: [PHP-DEV] preg_replace w/evaluations eats memory"
- Reply: Andrei Zmievski: "Re: [PHP-DEV] preg_replace w/evaluations eats memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've not had much luck using the bug system with lynx, so i'll dump
this one here.
If someone could submit, thanks.
<?php
/*
This program demonstrates a memory problem with preg_replace and
evaluations. The memory requirements of the script increase with
each iteration.
My original script was processing 2000 files, each with 10 preg
operations - hence 20,000 iterations. It's memory usage skyrocketed
to over 270mb.
This was tested on a FreeBSD 3.3 system with php4-200007141145
*/
/* create a virtual source file */
$data = str_repeat("xzxzxzxzxzxzzxxz<TAG>memory</TAG>zxzxzxzxzxz", 10);
function replace_eval($string) {
/* do nothing */
}
function replace() {
global $data;
$result = preg_replace("/(?x)
(<\/?) # 1 opening tag
(\w+) # 2 tag
([^>]*>) # 3 closing tag
([^<]*) # 4 body
/e",
"'replace_eval(\\4)'",
$data);
}
function loop() {
for ($i = 0; $i < 20000; $i++) {
replace();
}
}
loop();
?>
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Bug Database: "[PHP-DEV] PHP 4.0 Bug #5647 Updated: Compile failure"
- Previous message: Anantha Prasad/NE/USDAFS: "[PHP-DEV] Re: PHP 4.0 Bug #5647 Updated: Compile failure"
- Next in thread: Andrei Zmievski: "Re: [PHP-DEV] preg_replace w/evaluations eats memory"
- Reply: Andrei Zmievski: "Re: [PHP-DEV] preg_replace w/evaluations eats memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

