This content has been marked as final. Show 4 replies
Here's some articles which may help explain what's happening in your app:
Essentially, calling removeChild() does not neccessarily remove it from memory; it depends on several other factors.
"Russell.Brown" <firstname.lastname@example.org> wrote in message
> I'm building an image viewer that flips through images. Each image is
> in a component [Canvas] that stylizes the photo border. When I
> the memory is never reclaimed. Each photo I throw on the page increases
> memory with no decrease.
> As far as I can tell there are no references to these children. They are
> interacted with after creation accept to be destroyed. Is there another
> for destroying these? Removing a top level component would automatically
> all their children right? There should be no need to specifically delete
> image as well correct?
> Even just some help with debugging the reason via profiler would go a long
Why not just use one component, and change the Image's source property?
Because there are multiple images on the screen at once that are shuffled through. I could however create essentially a pool of objects and reuse them.
While there are multiple workarounds that I can see, for my own growth's sake I want to better understand why something wouldn't be collected at garbage time.
My current debacle is this. If I add a child and then remove it right away, everything works great. If I surround the removeChildAt(0) with an if statement making sure there are more than say 5 images, garbage collection fails to take back the memory from the removed children.
This makes absolutely now sense to me what so ever.
rtalton, thanks for the links, I'm trying my best to use them. While my understanding is better, I still can't figuere out why it doesn't work...
Hopefully something in those links will catch your eye.
Since there are many reasons why calling removeChild() doesn't always remove an object from memory, it's difficult to pinpoint without seeing all the code.
One thing that I noticed is if you have any kind of reference to the child, it will live on after you remove it. Maybe your code is still referring to it through a variable.
Also, this quote is from the help docs:
"The RemoveChild class removes a child display object, such as a component, from a container as part of a view state. The child is only removed from the display list, it is not deleted."
Do the components being removed have any event listeners? Remove them as you remove the components.