Skip to content

Commit

Permalink
Add a test case for a memory leak in xhprof_enable()
Browse files Browse the repository at this point in the history
  • Loading branch information
epriestley committed Feb 26, 2015
1 parent 4dbb1aa commit a64844d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions extension/tests/xhprof_012.phpt
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

0 comments on commit a64844d

Please sign in to comment.