44
Would it not make sense to try serializing the object and reading the string length? Obviously it will be several bytes off because serialized string would have s:'string' therefore s:'' being extra bytes... unless serialize could be the same way that PHP stores objects???
so for example
$size = strlen(serialize($object));
Just a thought?
Another messy but possibly accurate thought:
Assuming a class instance variable that has been manipulated a few times since instantiation:
$DB; // database access class for eg.
$mem = memory_get_usage();
$DB_tmp = clone $DB;
$mem = memory_get_usage() - $mem;
unset($DB_tmp);
$mem could be the exact amount of memory allocated to $DB;