What is the difference between recycled actors and regular actors?

Weasel8778

  • Posts: 236
I've never used recycled actors. I just don't know when I should use them as opposed to regular ones. Can anyone explain to me when I should use them? I read the Stencylpedia article and so have a basic understanding of them, but it didn't explain when it's best to use one kind of actor over the other.

Ambvai

  • Posts: 45
As I understand it, actors that are recycled stay in memory to be brought back out again at a moment's notice while killed actors are removed from memory and have to be recreated if they're brought out again. Assuming that's correct, recycling takes a bit more memory but is faster. As such, anything that's going to be introduced and removed over and over should be recycled. (Or in the context of games: Bullets and spawning enemies, among others.)

Hectate

  • *
  • Posts: 4643
It's kind of what Ambvai says.

Recycling actually will use less memory. A normal actor can be created and killed, created and killed, and each time that happens Flash is not entirely freeing up the computer's memory that is used by that actor.

A recycled actor on the other hand, is just kinda "deactivated" when it is killed. Because the designer knows that he'll need to create another one of those actors again - perhaps very soon - there's no sense in allocating new memory if you can just re-use the existing actor's again.

In essence, any one actor of either type will use the same amount of memory, but recycling the same 5 actors will only use 5 times that amount - while creating and destroying a new regular actor will use as much as you allow the player to create.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Ambvai

  • Posts: 45
Oh, and I'm not positive about this, but I THINK actors held in recycle-limbo are counted if you run a count of all actors in a scene. (I used to be convinced that was the case, then I noticed that behaviors relating to that actor are kind of wonky, so it might be something else.)

Weasel8778

  • Posts: 236
Thanks, but now it just seems like recycled actors are always superior? Is there any scenario to use just a regular actor?

Sunflower

  • Posts: 591
Well, probably there is. Note that recycled actors use up some memory, too. Now imagine that you have an epic RPG where you don't create/remove actors that often (except some fancy effect during battle scene ^^), but you encounter different actors a lot. Now, when you play longer this RPG, memory will be used much more than it should. At least that's what I can imagine if my understanding of recycled actors is correct. Oh well... O.o

Greg

  • *
  • Posts: 1260
Yeah, recycling Actors really only makes sense for things that you are probably going to kill off and reuse quite frequently.