Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60630 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42466 invoked from network); 21 May 2012 19:14:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 May 2012 19:14:04 -0000 Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain punkave.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:57248] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/74-16352-BF39ABF4 for ; Mon, 21 May 2012 15:14:04 -0400 Received: by yenm2 with SMTP id m2so5269261yen.29 for ; Mon, 21 May 2012 12:14:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=9DoPYM4X9Qj/PwDEPd7J8oOnW5jUhyii6jP1SPHv1Ko=; b=fQ25MrB/rapeWSIV5QdjyMxumDbhiheIq552qOTr4UzFywwy4per6XDHNgODcBy3HX IEiKwjuiktjDplZ+556FPk4q+Y2hOMVCYQHiNmTRW5c3wVQ32msny9bcnR/BVvEOLqY7 YcOg9wjhGrQnGObgs3hrdlJO5WLNS/L990RMln+214hGIGHc7+xJ/H8IFzEu60tnYqm+ hQIB9uGhJvmsz/oeGKwDPlD5vmQDoqYiX9CBUPVZkRq4I3JlATTLbrlLsUZUj2p/9s1m 8HB3Hc0q7ZFvmOmw98pYOOZm6XCaHYwooULr1qZSLDlmK85Z5tWW1+slhNcZDMs9QjOH FS5Q== MIME-Version: 1.0 Received: by 10.236.155.69 with SMTP id i45mr23760611yhk.68.1337627640442; Mon, 21 May 2012 12:14:00 -0700 (PDT) Received: by 10.100.109.13 with HTTP; Mon, 21 May 2012 12:14:00 -0700 (PDT) In-Reply-To: <4FBA8FB0.80104@sugarcrm.com> References: <4FBA8FB0.80104@sugarcrm.com> Date: Mon, 21 May 2012 15:14:00 -0400 Message-ID: To: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQnSQdnOBLebQZnWgDQgBxVkkz7iTwqjGc+SV1dDJhC3VOTDWwOBd8aJQCdXV+MpArWhXiYG Subject: Re: [PHP-DEV] memory usage ouchy From: tom@punkave.com (Tom Boutell) Yeah, dynamic properties get used by default every time you json_decode something, to take a random example. String folding could be used, but that would require a hashtable lookup and would probably be slower than allocation (at least until you started to swap). Worth testing maybe. Or... when you instantiate an object, it still looks like a hash, but declared property names are initialized to point at shared strings. Dynamic property names aren't. When the object is reclaimed, the declared properties are removed first to prevent double deallocations, and then the dynamic properties are destroyed. I'm suggesting a lot of work here I'm sure, but this latter idea seems like it might yield a large memory usage improvement. On Mon, May 21, 2012 at 2:55 PM, Stas Malyshev wrote: > Hi! > >> How come it's necessary to store the property-names of every property >> in every object? For properties that have been defined in classes, why >> can't they be stored in a more efficient manner? (using lookup tables) > > No because you can add and remove properties freely at runtime. > >> I know the nature of PHP is dynamic, and I know that dynamic >> properties would have to be stored in a key/value form internally... >> but if you look at modern PHP software, dynamic properties is actually >> something very few people use. > > This is not true. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com