Return-Path: X-Original-To: apmail-incubator-flex-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B80209B66 for ; Mon, 23 Jan 2012 19:52:50 +0000 (UTC) Received: (qmail 1952 invoked by uid 500); 23 Jan 2012 19:52:50 -0000 Delivered-To: apmail-incubator-flex-dev-archive@incubator.apache.org Received: (qmail 1852 invoked by uid 500); 23 Jan 2012 19:52:49 -0000 Mailing-List: contact flex-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-dev@incubator.apache.org Received: (qmail 1844 invoked by uid 99); 23 Jan 2012 19:52:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jan 2012 19:52:49 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aharui@adobe.com designates 64.18.1.181 as permitted sender) Received: from [64.18.1.181] (HELO exprod6og101.obsmtp.com) (64.18.1.181) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jan 2012 19:52:42 +0000 Received: from outbound-smtp-1.corp.adobe.com ([192.150.11.134]) by exprod6ob101.postini.com ([64.18.5.12]) with SMTP ID DSNKTx26dRQ25lU3a8BxZ/FcOzh/btQarMGs@postini.com; Mon, 23 Jan 2012 11:52:21 PST Received: from inner-relay-4.eur.adobe.com (inner-relay-4.adobe.com [193.104.215.14]) by outbound-smtp-1.corp.adobe.com (8.12.10/8.12.10) with ESMTP id q0NJoR0Y023369 for ; Mon, 23 Jan 2012 11:50:27 -0800 (PST) Received: from nacas01.corp.adobe.com (nacas01.corp.adobe.com [10.8.189.99]) by inner-relay-4.eur.adobe.com (8.12.10/8.12.9) with ESMTP id q0NJqJPl013762 for ; Mon, 23 Jan 2012 11:52:19 -0800 (PST) Received: from NAMBX02.corp.adobe.com ([10.8.127.96]) by nacas01.corp.adobe.com ([10.8.189.99]) with mapi; Mon, 23 Jan 2012 11:52:18 -0800 From: Alex Harui To: "flex-dev@incubator.apache.org" Date: Mon, 23 Jan 2012 11:52:16 -0800 Subject: Re: Flex 5 UIComponent - Behavior Pattern Thread-Topic: Flex 5 UIComponent - Behavior Pattern Thread-Index: AczZ/V4+327iCrGORmObL5j62brvFwACyOaZ Message-ID: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-Entourage/13.11.0.110726 acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 On 1/23/12 10:31 AM, "Doug McCune" wrote: > Alex, first, thanks for that memory breakdown, very helpful. >=20 >=20 >> The issue was not in the cost of the >> allocations, it was in the cost of an additional function call to run th= e >> actual work. Everything is now being proxied. >=20 >=20 > What if when setting the composited piece you always stored a hard > reference to all the functions, so something like this: >=20 > private var setFocusFunction:Function; > public function set focusBehavior(value:IFocusBehavior):void { >=20 > this.setFocusFunction =3D value.setFocus; //where setFocus() is a functio= n >=20 > } >=20 > and then when needing to set the focus, UIComponent calls > this.setFocusFunction() instead of calling focusBehavior.setFocus() >=20 > Since now the function is stored in UIComponent, does that get around the > perf. problem of always calling a proxy like focusBehavior.setFocus()? Actually, that makes it worse, espeically from a memory standpoint. Every cached function reference is just making the allocation size of the UIComponent larger and more inefficient. And, a function reference itself is some 100 bytes or so because it is a closure, not a pointer into code. I think the answer lies in selecting high-traffic sub-objects and caching their references (or not making them sub-objects at all and baking in their behaviors). As I keep saying, no one rule can be universally applied. --=20 Alex Harui Flex SDK Team Adobe Systems, Inc. http://blogs.adobe.com/aharui