在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;
}输出将是对象相对于环境设置的内存。
以上就是在PHP中获取对象在内存中的大小?的详细内容,更多请关注其它相关文章!
Php