獲取 PHP 中物件在記憶體中的大小?
可以在為已建立類分配記憶體之前和之後使用 memory_get_usage() 函式。
class MyBigClass {
var $allocatedSize;
var $allMyOtherStuff;
}
function AllocateMyBigClass() {
$before = memory_get_usage();
$ret = new MyBigClass;
$after = memory_get_usage();
$ret->allocatedSize = ($after - $before);
return $ret;
}輸出將是物件在環境設定方面的記憶體。
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP