|
-
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.
-
Senior Member
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
-
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.
-
Senior Member
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
-
Senior Member
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.
-
Are you talking about object pooling?
-
Senior Member
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
-
Developer
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.
-
Custom User Title
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|