function 内の include

test1.php

function foo() {
    global $color;
    $fruit = 'SUIKA';

    include 'test2.php';
    echo "A $color $fruit\n";
}

for ($i=0; $i<100; $i++) {
    foo();
    echo memory_get_usage() . "\n\n";
}

test2.php

$color = 'green';
$fruit = 'apple';

test1.php を実行したとき、メモリが増加する。

メモリ増加の原因は、ダブルクォーテーション内の変数展開であった。関数内のincludeはメモリを増やさない事がわかった。