Skip to content

Commit a64844d

Browse files
author
epriestley
committedFeb 26, 2015
Add a test case for a memory leak in xhprof_enable()
See <phacility#60>.
1 parent 4dbb1aa commit a64844d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
 

‎extension/tests/xhprof_012.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
XHProf: Memory Leak in Ignored Functions
3+
Author: epriestley
4+
--FILE--
5+
<?php
6+
7+
$old = memory_get_usage();
8+
9+
// This test covers a leak where the ignored function list would not be
10+
// deallocated properly after a new call to xhprof_enable().
11+
12+
$large = str_repeat('x', (1024 * 1024 * 16));
13+
xhprof_enable(0, array('ignored_functions' => array($large)));
14+
xhprof_disable();
15+
unset($large);
16+
17+
xhprof_enable();
18+
xhprof_disable();
19+
20+
$new = memory_get_usage();
21+
22+
$missing = ($new - $old);
23+
24+
if ($missing >= (1024 * 1024 * 16)) {
25+
echo "LEAKED A LOT OF MEMORY\n";
26+
} else {
27+
echo "DID NOT LEAK A LOT OF MEMORY\n";
28+
}
29+
30+
?>
31+
--EXPECTF--
32+
DID NOT LEAK A LOT OF MEMORY

0 commit comments

Comments
 (0)