Open BitOne opened 6 years ago
The prototype I mention in https://github.com/BitOne/php-meminfo/issues/83#issuecomment-432153953 will detect closures that would be provided to set_error_handler()
. It won't detect regular callables ( like 'myfunc'
or [$this, 'myfunc']
).
<?php
$b = 123;
set_error_handler(function () use ($b) { });
meminfo_dump(fopen('dump2.json', 'w+'));
would result in the following output/dump:
$ php -dextension=meminfo.so test3.php
Found unseen alive object: Closure #1 (0x7f0abea66640)
$ cat dump2.json
{
"header" : {
"memory_usage" : 391112,
"memory_usage_real" : 2097152,
"peak_memory_usage" : 427008,
"peak_memory_usage_real" : 2097152
},
"items": {
...
"0x7f0abea66640": {
"class" : "Closure",
"is_root" : false,
"frame" : "<OBJECTS_IN_OBJECT_STORE>",
"object_handle" : "1",
"type" : "object",
"size" : "56"
}
}
}
These callables could be Closure, hence objects that take some space in memory.