tags:

views:

23

answers:

1

I have a code like this:

        <mx:Repeater id="allItemRepeator" 
                     dataProvider="{_model.allItems}"
                     >
                <components:ComponentSelector id="componentSelector"
                                              dataLoad="{allItemRepeator.currentItem}"  />  
        </mx:Repeater>

When code changes for allItems the item disapears from screen as expected but still sits in memory! I know this by a function inside a compoenent that has "trace" so the trace output still displays even after the component disappears from screen. How do I ensure that the element is deleted when it's reference is deleted? Will using List-based component to display items instead of "Repeator" solve the problem (it requires significant refactoring of my code so I'm asking before trying it out)

A: 

Something is still holding onto a reference to the component, so it is not being garbage collected. Binding in particular (which I notice you are using) is notorious for this.

Best way to debug the problem is to run your application though the profiler and see what is keeping a reference to the component once it is removed.

Gregor Kiddie
Thanks @Gregor I currently don't have the Premium Flash Builder edition. Do you recommend another method until I upgrade?
Tam
Without seeing the code, it's really tough to know what's keeping the reference! The binding is the most likely culprit, but the component itself could be the issue if it's making strong EventListeners for example.Repeaters aren't really best practice because they have a few problems like this...
Gregor Kiddie
Thanks @Gregor it seems like having an EventListener on a photo was causing it! I manually deleted the items by adding an event handler for "removefromstage" for that component and it seems to work
Tam