Skip to main content
Inspiring
May 15, 2018
Question

Pooling Event objects

  • May 15, 2018
  • 1 reply
  • 1506 views

What is the real reason for not pooling flash Event objects? Is there any technical issue that is preventing Adobe implementing pooling for their internal objects like Event and TimerEvent and possibly SoundChannel?

If not for performance I am sure this can also help save a little battery on the device?

Why is Adobe so firmly against implementing pooling for those objects? Is that really that extremely dificult to implement?

This topic has been closed for replies.

1 reply

Inspiring
May 15, 2018

It's by design and it can be argue against but the reality is that Adobe won't change it since any change to those system could break existing implementations and Adobe is not interested in making AS3+. As far as Events, there are room for implementing your own pooling system, you can't stop events from being generated but you can limit their number. As for SoundChannel there's of course no solutions.

chakyAuthor
Inspiring
May 15, 2018

But honestly if you think about it, what kind of implementation would be broken if Adobe implements giving you the same object every frame instead of allocating new one? Can you think of any implementation that would break because of that?

Also when tested with Adobe Scout if I add listener to enter frame event on every frame 10kb more memory is allocated. If I do not add event listener for enter frame 10kb less is allocated on every frame. I think it is worth it.

Why is that such a big philosophy or a problem. Solution could not be more simpler. I would really like to hear if anyone knows any problem that could pop up if Adobe implements pooling of Event objects.

Inspiring
May 16, 2018

People who work with custom events (I do) often have to override the clone method. That method is automatically called when an event propagate through the display list and creates copies of the event for each child between the dispatcher and the receiver. This is also wasteful but the point is that people do have implementations in their code of that method. Now what would happen to that method if the event system was changed especially to an automatic pooling system, I can see how internally the clone method could be adjusted to fit with a pooling system but the existing implementations and overrides in frameworks might become off or might even break forcing people to rewrite/rethink those overrides.