4 Replies Latest reply on Jun 15, 2009 7:06 AM by flexchief

    UIComponent - Remove All BitmapData

    flexchief Level 1

      Hey,

       

      I'm using a cool flex component developed by Ely Greenfield called DisplayShelf. The compnent is used to display images in a fashion similar to the iTunes coverflow component - http://www.quietlyscheming.com/blog/components/tutorial-displayshelf-component/. This DisplayShelf component extends UIComponent.

       

      When I load more and more images into the DisplayShelf the performance begins to suffer, which I believe is due to the number of bitmap objects which are drawn as each image is added.

       

      My question is:

      Is there a way to completely remove all bitmap data from a UIComponent using the standard bitmapData.dispose() method or failing that is it possible to simply delete all UIComponent children from memory i.e. not to use removeAllChildren which still keeps them in memory?

       

      Thanks

      Adam

      Flexchief

        • 1. Re: UIComponent - Remove All BitmapData
          leybniz Level 4

          I guess, you could try to follow this sequence:

           

          1. Make sure you don't have any references to those objects, or at least have them weak references

          2. If you want to force GC to do it's job immediately just implement some "Empty/Dummy" lightweight module and load/unload it using ModuleLoader class, this action leads to GC invocation, and you should notice desired effect then..

           

          but it's a dirty hack

          1 person found this helpful
          • 2. Re: UIComponent - Remove All BitmapData
            flexchief Level 1

            Hi Alexander,

             

            Thanks a lot for your reply.

             

            I've found that by setting up a small loop to remove any children from the UIComponent and then loading additional images thereafter, I can improve the performance of the component hugely. Could this be because GC is grabbing the unreferenced children once they have been removed?

             

            In relation to your two suggestions: - Yep I've got all the related objects weak referenced as you mentioned but to be honest I was unsure about forcing GC invocation manually, partly because I really wasn't all that sure on how to do it, and because I had read some place that this was not really very good practice and could possibly cause some unwanted CPU processing issues?

            • 3. Re: UIComponent - Remove All BitmapData
              leybniz Level 4

              possibly yes, once you remove child it's a huge probability that nobody else reference this object, so GC invocation could take place

              Indeed manual manipulations on GC are unwanted.It's better to setup some limiting window for set of images and keep them the same, replacing them when needed to show up new ones, removing most old ones.

              1 person found this helpful
              • 4. Re: UIComponent - Remove All BitmapData
                flexchief Level 1

                Okay cool! I'll try that and keep you posted on how it works out...

                 

                Thanks again for your help Alexander.

                 

                Adam