Skip to content

Commit 3e7c419

Browse files
committed
Improved Zend Memory Manager to guarantee reasonable time for worst cases of best-fit free block searching algorithm.
1 parent 648b67c commit 3e7c419

File tree

4 files changed

+660
-330
lines changed

4 files changed

+660
-330
lines changed

Zend/tests/bug40261.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #40261 (Extremely slow data handling due to memory fragmentation)
3+
--INI--
4+
memory_limit=128M
5+
--FILE--
6+
<?php
7+
$num = 100000;
8+
9+
$a = Array();
10+
for ($i=0; $i<$num; $i++) {
11+
$a[$i] = Array(1);
12+
}
13+
14+
for ($i=0; $i<$num; $i++) {
15+
$b[$i] = $a[$i][0];
16+
}
17+
18+
unset($a);
19+
for ($i=0; $i<$num; $i++) {
20+
$b[$i] = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
21+
}
22+
echo "ok\n";
23+
?>
24+
--EXPECT--
25+
ok

Zend/tests/bug40809.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #40809 Poor perfomance of ".="
3+
--FILE--
4+
<?php
5+
error_reporting(E_ALL|E_STRICT);
6+
7+
$num_increments = 100;
8+
$num_repeats = 1000;
9+
$increment = 50;
10+
11+
/* Create some more holes to give the memory allocator something to
12+
* work with. */
13+
$num = 5000;
14+
$a = Array();
15+
for ($i=0; $i<$num; $i++) {
16+
$a[$i] = Array(1);
17+
}
18+
for ($i=0; $i<$num; $i++) {
19+
$b[$i] = $a[$i][0];
20+
}
21+
unset($a);
22+
23+
for ($i=0;$i<$num_repeats;$i++) {
24+
$evil = "";
25+
for ($j=0;$j<$num_increments;$j++) {
26+
$evil .= str_repeat("a", $increment);
27+
}
28+
unset($evil);
29+
}
30+
echo "ok\n";
31+
?>
32+
--EXPECT--
33+
ok

0 commit comments

Comments
 (0)