Hi!
Given this, sometimes it's easy to forget that PHP is pathologically memory hungry, to the point of making simple tasks difficult or impossible to perform in limited environments. It's the worst language I've ever encountered in this respect. An array of small strings will use on the order of 200 bytes per element. An array of integers will use
HashTable uses 40 bytes, zval is 16 bytes, Bucket is 36 bytes, which means if you use integer indexes, the overhead is 72 bytes per value including memory block headers and alignments. It might be too much for you, in which case I'd go towards making an extension that creates an object storing strings more efficiently and implementing either get/set handlers or ArrayAccess (or both). This of course would be most useful if you access only small part of strings in each function/method.
I do not see what could be removed from Bucket or zval without hurting the functionality.
not much less. A simple object (due to being based on the same inefficient data structure) may use a kilobyte or two.
Kilobyte looks like too much for a single simple object (unless we have different notions of simple). Could you describe what exactly makes up the kilobyte - what's in the object?
* Objects that can optionally pack themselves into a class-dependent structure and unpack on demand
Objects can do pretty much anything in Zend Engine now, provided you do some C :) For the engine, object is basically a pointer and an integer, the rest is changeable. Of course, on PHP level we need to have more, but that's because certain things just not doable on PHP level. Do you have some specific use case that would allow to reduce
* Exposing strongly-typed list and vector data structures to the user, that don't have massive hashtable overheads * An oparray format with less 64-bit pointers and more smallish integers
Ah, you're on 64-bit... That explains why your memory requirements is larger :) But I'm not sure how the data op array needs can be stored without using pointers.
-- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php