Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60635 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51139 invoked from network); 21 May 2012 20:28:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 May 2012 20:28:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.155 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.155 smtp155.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.155] ([67.192.241.155:36529] helo=smtp155.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/26-16352-185AABF4 for ; Mon, 21 May 2012 16:28:52 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp32.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 60D37501C8; Mon, 21 May 2012 16:28:46 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp32.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id A3F68501A2; Mon, 21 May 2012 16:28:45 -0400 (EDT) Message-ID: <4FBAA57D.2000400@sugarcrm.com> Date: Mon, 21 May 2012 13:28:45 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Tom Boutell CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] memory usage ouchy From: smalyshev@sugarcrm.com (Stas Malyshev) 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