PHP ဖွံ့ဖြိုးတိုးတက်မှုတွင်သိုလှောင်ထားသောအရာဝတ်ထုများ၏မှတ်ဉာဏ်ပမာဏကိုနားလည်ခြင်းသည်စွမ်းဆောင်ရည်အကောင်းဆုံးနှင့်မှတ်ဉာဏ်စီမံခန့်ခွဲမှုများကိုကူညီနိုင်သည်။ We can use the PHP built-in function memory_get_usage() to call it before and after creating the object, and calculate the memory actually allocated by the object.
class MyBigClass {
var $allocatedSize;
var $allMyOtherStuff;
}
<p>function AllocateMyBigClass() {<br>
$before = memory_get_usage();<br>
$ret = new MyBigClass;<br>
$after = memory_get_usage();<br>
$ret->allocatedSize = ($after - $before);<br>
return $ret;<br>
}
function function ကို allocatemybigclass () ပထမ ဦး စွာလက်ရှိမှတ်ဉာဏ်အသုံးပြုမှု $ မတိုင်မီ , ထို့နောက် mybigclass object တစ်ခုဖန်တီးပါ, ထို့နောက်ဖန်တီးထားသောမှတ်ဉာဏ်အသုံးပြုမှု $ ကို $ ပြီးနောက် မှတ်တမ်းတင်ပါ။ နှစ်ခုအကြားနုတ်သည်အရာဝတ်ထုမှသိမ်းပိုက်ထားသောမှတ်ဉာဏ်ဖြစ်ပြီး, ရလဒ်ကိုအရာဝတ်ထု၏ ခွဲဝေ ပစ္စည်းပိုင်ဆိုင်မှုတွင်သတ်မှတ်ထားသည်။
ဤနည်းဖြင့်တိုင်းတာသောမှတ်ဉာဏ်အရွယ်အစားသည်သဘာဝပတ်ဝန်းကျင်နှင့်သဟဇာတဖြစ်မှုနှင့်ပါ 0 င်သော Memory Memory Management Mericism မှသာအကျိုးသက်ရောက်နိုင်သည်။ လက်တွေ့ကျကျလျှောက်လွှာတွင်၎င်းကိုအခြားကိရိယာများနှင့်နည်းလမ်းများနှင့်ပြည့်စုံသောဆန်းစစ်ရန်အခြားကိရိယာများနှင့်နည်းလမ်းများနှင့်ပေါင်းစပ်နိုင်သည်။