IMHO, the player and the hosting browser get really unpredictable once you get 
past 500MB or so.  Hopefully you’ll be able to stay below that and your app 
will be stable.


On 2/23/10 9:08 AM, "Aaron Hardy" <[email protected]> wrote:






Thanks Alex for the follow-up.  Your questions prompted me to dig into the 
memory load more and it looks like we had some bad memory issues.  
Specifically, when the user selects a bunch of photos, we load those images in 
using file.load() and then generate small thumbnails from the loaded data.  The 
problem was we were keeping around the file references while the files were 
also being uploaded. The full file data (stored in the data property on 
FileReference) was no longer needed in the app after the thumbnail was 
generated but we were hanging onto it anyway.  By calling file.data.clear() 
after generating each thumbnail we were able to free up that memory...which was 
a LOT of memory.

So, the short story is there DOES seem to be some funky business in Loader when 
Flash Player is under a lot of memory stress.  On the flip side we've reduced 
the memory stress sufficiently to hopefully not run into the issue in the first 
place.  To answer your questions anyway:

The process memory was up around 1 GB before we starting running into trouble 
(with proper memory cleanup this is dramatically lower).  This is on a 4 GB 
memory Windows Vista machine and I had quite a few other applications open 
(Flex Builder, Illustrator, etc.)

I had loaded in 450 images with each being roughly 1.5 MB each as compressed 
JPGs and we were creating thumbnails at about 150x100 pixels each (~60k in 
BitmapData each or ~27MB for 450 thumbnails).  Reports from other people show 
they were getting problems with less than 200 images but we haven't dug into 
the details of the size of their images, etc.

In our test, all 450 thumbnails were still around which took up around 27 MB.  
And, because of improper memory cleanup, 450 full bitmaps loaded from the hard 
drive were still in memory also.

Thanks for the help.  Hopefully that will clear up our problems.

Aaron

On Mon, Feb 22, 2010 at 11:15 PM, Alex Harui <[email protected]> wrote:





How much process memory is the browser using when you run into trouble?

How many images have you loaded?

How many of those images are still around?



On 2/22/10 4:48 PM, "Aaron Hardy" <[email protected] 
<http://[email protected]> > wrote:






And yet another update.  Sorry for the large number of emails.  It looks like 
the more and more I use the application and add stress to the Flash Player the 
smaller the image must be in order to avoid the 0 dimensions issue.  In other 
words, if the Flash Player doesn't have much stress I can load an image that's 
24 million pixels just fine.  As I add more stress and then attempt to load the 
same image, I'll start to get 0 width and height, but I'll be able to load a 14 
million pixel image (4350x3263=14.1 million pixels) just fine.  If I continue 
adding stress to the Flash Player and I continue to load the same 14 million 
pixel image I'll start to get 0 width and height for that image, even if it's 
under the bitmap limits.  At that point I can load a 12 million pixel image 
fine.  If I continue to use the app and add stress, I'll soon not be not even 
be able to load the same 12 million pixel image.  This imaginary limit seems to 
get smaller and smaller over time and has very little, if anything, to do with 
Flash's max bitmap dimensions.

Aaron

On Mon, Feb 22, 2010 at 5:12 PM, Aaron Hardy <[email protected] 
<http://[email protected]> > wrote:
I've gathered additional information.  It appears that it's due to bitmaps that 
are over the supported size (16,777,215 pixels).  While the bitmaps load in 
fine when the Flash Player isn't under much stress, the width/height choke when 
there is stress.  Again, it isn't consistent, but that seems to be the issue.  
I read somewhere that when loading a bitmap in using Loader that the maximum 
dimensions didn't apply, but that appears to not be the case and from Adobe 
I've only heard that all bets are off with bitmaps over 16,777,215 pixels.

I'll update the thread if it turns out to be something different.

Aaron


On Mon, Feb 22, 2010 at 4:28 PM, Aaron Hardy <[email protected] 
<http://[email protected]> > wrote:
It's not any particular photo or set of photos.  Sometimes we can run the app 
and load the photos just fine then the next day we'll attempt to load the same 
files and the width/height will return 0.  It seems that once the issue starts 
to occur that any time we try to upload any photo within that session it 
continues reporting width/height of 0. There's not a very reproducible pattern 
though it seems to occur more frequently when the Flash Player is under heavy 
stress like when it's trying to load in many files at the same time.  It also 
seems to happen more frequently if we have two tabs open with the same 
application loaded in both and we're attempting to load the same images in both 
tabs (this may be related to the stress the Flash Player is under rather than 
some sort of file locking issue).  Again, it doesn't always happen, just more 
frequently under those scenarios.  We've created a queue so only one photo is 
loading in at a time and we even threw in the Grant Skinner hack of forcing 
garbage collection between each load to see if that would help.  That did 
actually decrease the frequency of the issue quite a bit but not sufficiently.

Since posting we've tweaked the code slightly to use the width/height 
properties on the bitmapdata instead of the bitmap itself.  I doubt it will 
make any difference but at least it narrows it down a bit.

Aaron


On Mon, Feb 22, 2010 at 1:05 PM, Alex Harui <[email protected] 
<http://[email protected]> > wrote:





Is there a particular file that gives you trouble or wil it load successfully 
at some other point?



On 2/22/10 10:06 AM, "Aaron Hardy" <[email protected] 
<http://[email protected]>  <http://[email protected]> > wrote:






Flexers,

We have an app that allows a user to upload images.  When the user selects an 
image, we load the bitmap from the hard drive and create a thumbnail from it.  
However, every once in a while the bitmap will return 0 for both width and 
height which causes issues later on.  That vast majority of the time the 
width/height are returned correctly.

Here's the basic code of the image loading--it's nothing special:

====================================

        override public function execute():void
        {
            file.addEventListener(Event.COMPLETE, fileLoadedHandler);
            file.addEventListener(IOErrorEvent.IO_ERROR, fileLoadErrorHandler);
            file.load();
        }

        /**
         * The files bytes were loaded successfully.
         */
        protected function fileLoadedHandler(event:Event):void
        {
            file.removeEventListener(Event.COMPLETE, fileLoadedHandler);
            file.removeEventListener(IOErrorEvent.IO_ERROR, 
fileLoadErrorHandler);

            var ba:ByteArray = file.data;
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
bitmapLoadedHandler);
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
bitmapLoadFailedHandler);
            loader.loadBytes(ba);
        }


        /**
         * The bitmap was successfully loaded from the file's bytes.
         */
        protected function bitmapLoadedHandler(event:Event):void
        {
            loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, 
bitmapLoadedHandler);
            loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, 
bitmapLoadFailedHandler);

            try
            {
                var fullSizeBitmap:Bitmap = Bitmap(loader.content);

                if (fullSizeBitmap.width == 0 || fullSizeBitmap.height == 0)
                {
                    // There's a problem.
                }
        ...

====================================

Any idea why this would be the case?   Is it a Flash Player bug?  Any help is 
much appreciated.

Aaron





--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to