forked from longxinH/xhprof
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test case for a memory leak in xhprof_enable()
See <phacility#60>.
- Loading branch information
epriestley
committed
Feb 26, 2015
1 parent
4dbb1aa
commit a64844d
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
XHProf: Memory Leak in Ignored Functions | ||
Author: epriestley | ||
--FILE-- | ||
<?php | ||
|
||
$old = memory_get_usage(); | ||
|
||
// This test covers a leak where the ignored function list would not be | ||
// deallocated properly after a new call to xhprof_enable(). | ||
|
||
$large = str_repeat('x', (1024 * 1024 * 16)); | ||
xhprof_enable(0, array('ignored_functions' => array($large))); | ||
xhprof_disable(); | ||
unset($large); | ||
|
||
xhprof_enable(); | ||
xhprof_disable(); | ||
|
||
$new = memory_get_usage(); | ||
|
||
$missing = ($new - $old); | ||
|
||
if ($missing >= (1024 * 1024 * 16)) { | ||
echo "LEAKED A LOT OF MEMORY\n"; | ||
} else { | ||
echo "DID NOT LEAK A LOT OF MEMORY\n"; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
DID NOT LEAK A LOT OF MEMORY |