Re: memory usage ouchy

From: Date: Mon, 21 May 2012 20:28:45 +0000
Subject: Re: memory usage ouchy
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-60635@lists.php.net to get a copy of this message
Hi! > 262144 bytes used > > That is definitely a significant improvement. > > Objects are still a lot bigger than their contents. I don't expect > they would ever shrink to the size of their contents exactly or even > all that close of course. Hashtables and zvals have overhead. So if you store 4-byte value, you have: zval wrapper - 16 bytes allocation unit - 8 bytes IIRC hashtable bucket - 36 bytes So you are already at 60 bytes per value. That's on 32-bit, on 64-bit due to pointers and longs being wider, probably almost double that. Then also add the storage for the key itself. If you need more memory-efficient data storage, something like SplFixedArray may help. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#60635) next »