I tried all the suggestions above for getting the object size (in bytes) for $memsize, but they didn't work universally for the two types of objects I tried (string and array of strings).After doing some googling and experimenting, I have found the following magic formula:$memsize = ( strlen( serialize( $object ) ) + 44 ) * 2;I found this in someone else's code, so I can not explain it.