A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Garbage Collection Problems? Not yet...

  1. #1
    Member
    Join Date
    Jan 2009
    Location
    Texas
    Posts
    75

    Garbage Collection Problems? Not yet...

    Well.. I'm confoosed. During my crash course on AS3 coding I read several comments where peeps were taking measures to speed things up by pooling, creating arrays that never change size, etc, etc. In affect doing things so the garbage collection never gets called. But what I'm confused about is, in my game I'm moving around alot of objects just using pushing and slicing arrays and I'm not noticing any problems what-so-ever. My game runs at a 20fps on my old test kit and 30fps (the target rate) on modern hardware. So is this really an issue or does the flash 10 player have enhanced gc features that make this less of an issue? Thanks.

  2. #2
    Senior Member hatu's Avatar
    Join Date
    Jan 2007
    Posts
    480
    That's a pretty unspecific question. It probably won't be an issue in most projects. Properly working garbage collecting is pretty much invisible, you might take a 1fps hit for a few frames
    http://hatu.biz
    Portfolio & games

  3. #3
    Member
    Join Date
    Jan 2009
    Location
    Texas
    Posts
    75
    Thanks for the reply. Granted a little vague, sorry. I'm just surprised how well everything is working without getting "down and dirty" and doing tons of optimizations, etc, etc. As I get closer to being done with this game, I keep waiting for the "big one" to hit which throws everything out the door. Come to think of it, I do get a slight hit in frame rate once in a while, but like you said it's only 1-2 frames max for a second or 2. If that's as bad as it gets then I can live with that.

  4. #4
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,361
    I think the main thing to remember is that it is the graphics that will normally cause the slowdown, not the scripts you are running(especially in AS3). With that in mind, these optimizations can be useful, more so in specific instances, but the amount of return is probably much less than optimizing how things are drawn etc..

    UG

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Instead of fps you should perhaps watch memory usage. If the memory used by Flash Player get higher and higher it means garbage collector is never called.

    Also, garbage collector does not work every frame, meaning your average fps wont be lowered but you may get noticable lag-spikes where sometimes game hangs for second or so, this can be garbage collector crawling though unused objects.

  6. #6
    Senior Member
    Join Date
    Feb 2004
    Posts
    782
    Are you talking about object pooling?
    Flash Ninja Clan - Games and cartoons

  7. #7
    Senior Member charlie_says's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    508
    On a similar vein, do you need to remove every addEventListener that you use...

    so basically, if I us

    root["upload"].addEventListener(MouseEvent.CLICK,uploadHandler);

    should I include the removeEventListener as part of the function uploadHandler??

    Thanks,

    Charlie

  8. #8
    Developer dVyper's Avatar
    Join Date
    Oct 2008
    Location
    UK
    Posts
    168
    You 'should' most definitely yes.

    But in the average game that doesn't use that much memory and will only be running for about 10 minutes you really don't have anything to worry about.

  9. #9
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    I bet you didnt use movieClips with sounds inside
    But anyway, polling is still better because the time it takes to recycle objects is a lot smaller than if you were creating/erasing them all the time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center