3 Replies Latest reply on Nov 3, 2009 2:35 PM by Aaronius9er9er

    Garbage collection crashing flash player

    Aaronius9er9er Level 1

      Hey flexers,

      My team has been building an application that's graphically heavy.  The  heaviest portion consists of two sprites that are ~4000x4000 pixels and  have a bunch of sprite children and ~20 bitmaps each.  The content ends  up being ~30 MB for both sprites total, give or take 20 MB.  When it's  time to switch to new sprites with new content we make sure there are no  more references to the two old sprites.  I've verified that garbage  collection does clean up the old content each time and memory stays  about even.  However, quite commonly (maybe 1 out of 3 times) when  switching to two new sprites the Flash Player will crash.  I have good  reason to believe it's the act of garbage collection that is causing  this crash.  Here's why:

      (1) If I'm in the Flex Profiler and I've switched to two new sprites and  then I hit "run garbage collection" it will sometimes crash right at  that moment.
      (2) If I use Grant Skinner's posted hack of forcing garbage collection  it will sometimes crash right when the garbage collection is forced.
      (3) If I keep a reference to all the old sprites (so garbage collection  won't collect them) it doesn't crash even after switching to new sprites  over 25 times, however the application uses more and more memory.

      Can someone provide some enlightenment as to how we proceed?  We don't  want the application crashing frequently but we also don't want to hog  the user's memory (and eventually cause a crash anyway).  Making the  sprites smaller is an obvious route but one of the last routes we want  to take because they're that large for a reason.

      Thanks.  We appreciate any help offered!

      Aaron