PHP memory usage increase after unsetting arrays?
<p>I run the code below without unsetting the arrays and then with unsetting the arrays using PHP's  </p>

<p>unset($array-here)</p>

<p>And the memory number increases when I use the unset.  Any ideas why?  ANd better yet, what is the proper way to free memory?  </p>

<p><strong>NOTICE: PLEASE, no preaching about pre-optimizing, its EVIL and all that, this is a test so don't lecture about it please and thank you.</strong></p>

<pre><code>//show current memory usage BEFORE
echo memory_get_usage() . "\n"; // 57960

//start timer
$start3 = microtime(true);
// arrays for header menu selector
$header_home = array('home'  =&gt; true);
$header_users = array('users.online' =&gt; true, 'users.location' =&gt; true, 'users.featured' =&gt; true, 'users.new' =&gt; true, 'users.browse' =&gt; true, 'users.search' =&gt; true, 'users.staff' =&gt; true);
$header_forum = array('forum' =&gt; true);
$header_more = array('widgets'  =&gt; true, 'news'  =&gt; true, 'promote'  =&gt; true, 'development'  =&gt; true, 'bookmarks'  =&gt; true, 'about'  =&gt; true);
$header_money = array('account.money' =&gt; true, 'account.store' =&gt; true, 'account.lottery' =&gt; true, 'users.top.money' =&gt; true);
$header_account = array('account'  =&gt; true);
$header_mail = array('mail.inbox' =&gt; true, 'mail.sentbox' =&gt; true, 'mail.trash' =&gt; true, 'bulletins.post' =&gt; true, 'bulletins.my' =&gt; true, 'bulletins' =&gt; true);

//run throught 1,000 iterations
for($i = 0; $i &lt; $iterations; ++$i) {
if(isset($header_home[$p]))
    $current_home = 'current';
else if(isset($header_users[$p]))
    $current_users = 'current';
else if(isset($header_forum[$p]))
    $current_forum = 'current';
else if(isset($header_more[$p]))
    $current_more = 'current';
else if(isset($header_money[$p]))
    $current_money = 'current';
else if(isset($header_account[$p]))
    $current_account = 'current';
else if(isset($header_mail[$p]))
    $current_mail = 'current';
}
//unset the arrays
unset($header_money);
unset($current_home);
unset($current_users);
unset($current_forum);
unset($current_more);
unset($current_account);
unset($current_mail);

//show time
$end3 = microtime(true);
echo number_format($end3 - $start3, 7) . ' Time3 ARRAY&lt;br /&gt;';

//show current memory usage AFTER
echo memory_get_usage() . "\n";
</code></pre>
