- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
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;
}
MyBigClass * AllocateMyBigClass() {
# MyBigClass ret;
MyBigClass * ret = malloc(sizeof(MyBigClass));
# ret.allocatedSize = sizeof(MyBigClass);
ret->allocatedSize = sizeof(MyBigClass);
Since clone (from Prof83's answer) didn't work for me, I tried to serialize and unserialize the variable whose size I want to measure:
Уверен, что можно обойтись без этого.
https://true-coder.ru/php/iterirovanie-obektov-v-php-vstroennye-klassy-iteratory-obekt-kak-massiv.html
Для заданий в рамках специальной олимпиады
И чего это он должен ко мне пиздовать?
да!