Is there a function in PHP (or a PHP extension) to find out how much memory a given variable uses? sizeof
just tells me the number of elements/properties.
See:
Note that this won't give you the memory usage of a specific variable though. But you can put calls to these function before and after assigning the variable and then compare the values. That should give you an idea of the memory used.
You could also have a look at the PECL extension Memtrack, though the documentation is a bit lacking, if not to say, virtually non-existent.