Jump to content
Search Community

manual garbage collection

eigenface test
Moderator Tag

Recommended Posts

It looks like every 60 frames, references to dead tweens are removed so the garbage collector can free the memory. The optimal period of time between when dead tweens are referenced depends upon how tweenmax is being used, i.e. how many tweens are being created. Would it be possible for the user to adjust this 60 frames? Actually, figuring out the absolute best number of frames between dereference passes is difficult, and may not offer much performance benefit over just using 60. I'm not sure.

 

What I am pretty sure about is sometimes it would definitely be better have control of exactly when the dead tweens get derefernced. Garbage collecting a large number of objects can make the flash player frame drop momentarily or skip, breaking up an otherwise smooth animation. I've often wished I could tell the garbage collector not to run for a certain period of time (while the animation is going on), then tell it to run immediately afterward (while nothing is animating), then tell it not to run while the next animation is going on, etc. I can't directly control the garbage collector in flash, but I can prevent it from having a reason to run by not dereferencing any objects. With tweenmax, you could potentially allow me to do this, at least for tween objects. You could have functions to enable and disable periodic dead tween dereferencing, and also a function to immediately dereference all dead tweens. I know when my app can afford to have the garbage collector run and remove dead tweens, and when I'd prefer not, so the animation won't skip.

 

Would it be possible to add a function to enable and disable periodic dereferencing, and a function to immediately dereference all dead tweens? And maybe even a function to set the frequency of the periodic dereferencing that goes on.

Link to comment
Share on other sites

The more functions I add, the more kb and the more complex things appear to users, and since the dereferencing happening every 60 frames should really be a non-issue (I've had it cranking through 8000 tweens per second without any noticeable burping when the dereferencing happens), I don't want to add this sort of functionality. Really, that code loop every 60 frames would be dwarfed by the code that has to drive all the animations if you're doing some heavy lifting, so it would be extremely unlikely that it would ever cause the slightest hiccup. The thing that may actually cause a slight stutter under heavy loads is when Flash's gc kicks in which is completely unpredictable and is not tied to TweenLite/Max in any way. If you're straining the engine so much that the dereferencing routine inside TweenLite causes any perceivable slowdown (which again is EXTREMELY unlikely), you might want to write your own code loop instead of using a tweening engine anyway.

 

I appreciate the suggestion, though - feel free to keep 'em coming.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...