Hmm, maybe I am missing something here? The only place I see
addEventListener being called is
protected function startTrackUpdates(item:Object):void
{
if (item && (item is IEventDispatcher))
{
IEventDispatcher(item).addEventListener(
PropertyChangeEvent.PROPERTY_CHANGE,
itemUpdateHandler, false, 0, true);
}
}
which has the weak-keys boolean flag turned on. Shouldnt that allow garbage
collection to run without explicitly calling removeEventListener ?
On Thu, Feb 14, 2008 at 11:54 PM, Alex Harui <[EMAIL PROTECTED]> wrote:
> Our code has to look like that otherwise if someone kept a reference to
> one of the objects that got removed, it would keep the ArrayList from being
> GC'd. We added listeners, so we should remove them. If the data objects
> are going away too, then you can probably reset the source, but if you see a
> memory leak later, I'd definitely check in that area.
>
>
> ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Arpit Mathur
> *Sent:* Thursday, February 14, 2008 8:27 PM
> *To:* [email protected]
> *Subject:* [flexcoders] Performance difference between
> ArrayCollection.removeAll() and ArrayCollection.source = []
>
>
>
> I was trying to debug an issue with the LogBook application we released a
> couple of days back. If you take a look at the interface on the main page at
> http://cimlogbook.googlecode.com (or if you have installed the
> application), you will see a clear logs button. Clicking on that clears an
> ArrayCollection that holds a series of LogObjects by calling a removeAll()
> function. However we got a bug saying the application would almost hang if
> it tried to clear a lot of messages. A quick patch was to reset the source
> like so: arrayCollection.source = [] . The performance became lightning
> fast.
>
> Looking deeper into the removeAll function and following the hierarchy to
> the ArrayList class, I see that the removeAll loops through the entire
> array, looking at each member to see if its an event dispatcher and if so
> calling a function to remove the propertyChange listener.
> Why is this implemented this way ? Is there any reason I shouldnt just use
> source = [] to reset the array ?
>
> Thanks
>
>
> --
> Arpit Mathur
> Lead Software Engineer,
> Comcast Interactive Media
> ---------------------------------------
> post your flex tips on
> http://flextips.corank.com
>
>
--
Arpit Mathur
Lead Software Engineer,
Comcast Interactive Media
---------------------------------------
post your flex tips on
http://flextips.corank.com