Ben diziler unsetting olmadan ve daha sonra PHP'nin kullanarak diziler unsetting ile aşağıdaki kodu çalıştırmak
unset (array-$ burada)
Ben unset kullandığınızda ve bellek sayı artar. Herhangi bir fikir neden? Ve daha iyisi, belleği boşaltmak için doğru yolu nedir?
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.
//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' => true);
$header_users = array('users.online' => true, 'users.location' => true, 'users.featured' => true, 'users.new' => true, 'users.browse' => true, 'users.search' => true, 'users.staff' => true);
$header_forum = array('forum' => true);
$header_more = array('widgets' => true, 'news' => true, 'promote' => true, 'development' => true, 'bookmarks' => true, 'about' => true);
$header_money = array('account.money' => true, 'account.store' => true, 'account.lottery' => true, 'users.top.money' => true);
$header_account = array('account' => true);
$header_mail = array('mail.inbox' => true, 'mail.sentbox' => true, 'mail.trash' => true, 'bulletins.post' => true, 'bulletins.my' => true, 'bulletins' => true);
//run throught 1,000 iterations
for($i = 0; $i < $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<br />';
//show current memory usage AFTER
echo memory_get_usage() . "\n";