Recycling vs Spawn/Destroy?

SocksSocks London, UK.Member Posts: 12,822
Do we still need to recycle our actors with the latest version of GameSalad ?

I know that's been the accepted wisdom for a long time now, if you are in the business of generating lots of actors (for instance: bullets from a gun) then people say you should really be recycling your actors.

But I just ran a test (GS 0.10.1 / iPad3) where I am 'firing' objects from a spawner actor on the left hand side of the screen which are then travelling across the screen and being destroyed by a 'killer' object on the right hand side of the screen.

There are around 110 objects on the screen, travelling towards the killer object, at any one time

The spawner is firing with a timer every 0.0 seconds (so as fast as it can).

I've left this running on my iPad for a while now - I have a large object counter on screen and so far have fired over 168,000 objects (one hundred and sixty eight thousand objects !!) across the screen and destroying them on the other side whilst monitoring the performance read out.

The frame rate has remained consistent at 60fps.
The 'Game Engine' size has remained around 4.5Mb
The 'Other' size has remained around 31Mb
The 'Total' has remained around 36Mb

Do we really still need to worry about recycling actors ?

Opinions welcome.

Comments

  • DeadlySeriousMediaDeadlySeriousMedia ArizonaMember Posts: 838
    I have an endless runner I've been working on and I get better results with spawn/destroy than with recycle. My obstacles have some rules and having enough of 5 different obstacles on screen to make them appear random was really dragin down performance. It's faster now that the spawner randomly spawns an obstacle then destroys it after is goes by the screen.
  • 3itg3itg Member, PRO Posts: 382
    I have a project where I saw very little improvement between the two methods.
    I will test this right now report back as soon as I know... shouldn't take long if nothings changed, since I could pretty consistently produce a crash in under 5 minutes.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Yeah that"s like a method from ages ago when Apple was on ARMV6 chips now it's a non-issue. I always spawn! Lot's of wives tales float around here.
  • SocksSocks London, UK.Member Posts: 12,822
    Yeah that"s like a method from ages ago when Apple was on ARMV6 chips now it's a non-issue. I always spawn! Lot's of [old] wives tales float around here.
    Cheers for the input, do you know which devices are ARMV6 ? (iPad 1?)
  • RPRP Member Posts: 1,990
    edited December 2012
    Armv6 is in iPhone (original) , iPhone 3G, iPod touch first gen, iPod Touch second gen

    Armv7 is found in iPhone 3GS and up. iPad 1 and up, iPod touch 3rd gen and up.

    The original iPad has an earlier family member of the Armv7 club.

  • 3itg3itg Member, PRO Posts: 382
    I still crash. But it was worth a shot...
    But I am under the assumption that my issues with this will be addressed with the new engine. So, back to making a different game while I wait :)
  • SocksSocks London, UK.Member Posts: 12,822
    Armv6 is in iPhone (original) , iPhone 3G, iPod touch first gen, iPod Touch second gen

    Armv7 is found in iPhone 3GS and up. iPad 1 and up, iPod touch 3rd gen and up.

    The original iPad has an earlier family member of the Armv7 club.


    Cheers RP, useful information. : )
  • SocksSocks London, UK.Member Posts: 12,822
    I still crash. But it was worth a shot...
    But I am under the assumption that my issues with this will be addressed with the new engine. So, back to making a different game while I wait :)

    What device are you viewing the spawning+destroy on?
  • 3itg3itg Member, PRO Posts: 382
    edited December 2012
    iPad 3
    (I have done everything I can to optimize over the past few months, removing and optimizing code, replacing timers, limiting auto-saves... I have come to terms with the fact that I overbuilt for the current iteration of game salad)
  • SocksSocks London, UK.Member Posts: 12,822
    iPad 3
    That's odd, I am using an iPad3 too and all my spawn destroy experiment have passed off without incident, I've thrown out tens of thousands of spawned actors - all getting destroyed - and I've never had a crash ?

    Can you post the troubled scene (strip out any bit you don't want people to see) ???
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    It sounds like your file is messed up. Doing a lot of deleting and changing can cause problems with a file.
  • UtopianGamesUtopianGames Member Posts: 5,692
    edited December 2012
    Spawn and destroy is loads loads loads better than it used to be, i think i was one of the 1st to share the recycle methods ways back then in the older version of the engine because it needed to be done but like i say its a million times better now and i used it for our latest game Blood Flow.

    If an actor is more than 500 away from your scene size it will automatically be destroyed so there's even an argument for not destroying at all under certain situations.

    Darren.
  • DanielDoeDanielDoe Member Posts: 307
    Last time I was using recycling was about 3 months ago. Since last two versions of GS I'm using only spawn/destroy behavours and it works perfect.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    What I'm hearing is that if you try to spawn a ton of actors at once, you'll still get the slowdown/crash . . . . .
    From what I tell it doesn't matter how many actors you spawn at once, I've tried my utmost to spawn as many actors as I could simultaneously - with at least 120+ on screen at anyone time within a stream of hundreds of thousands (literally) and have not been able to impact on either performance or memory usage of the target device.

    Like I say elsewhere, if you (or anyone) has any examples of this slowdown/crash I'd be keen to take a look - I've not been able to reproduce it myself, but if you can knock up a quick project that spawns enough actors to cause a slowdown on a target device it would be worth sharing it.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    ..
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Hehe it was actually 153,600 actors at once. Using the tile spawning thing @rthurman set it to do 1x1 actors to cover the screen. Obviously I never expected it to work but I figured I had to try anyway. I have a feeling it would be a bit touch for any sdk.

    As far as spawn vs recycle I have not messed with recycling for a year now. It just hasn't made sense as this is an area GS has been heavily improving on. Most cases these days I would spawn and destroy over recycle. Obviously there are situations you might find it more efficient from a coding standpoint but based straight off performance there's no benefit with using recycle. Same with reset scene. It's 100 times better than it used to be so why bother with coding in an instant reset system they is essentially a more in depth recycling system. It's a bunch if extra work that is just simply not needed IMHO.

    Cheers
  • POMPOM Member Posts: 2,599
    edited December 2012
    Just want to throw my 2 cents in here..
    I also stopped recycling but my reason was different, in my project I had 60 optional different actors that may be spawned, at first I used the recycling method (that was about 10 months ago) but the recycling method, however efficient it might be, killed my game, those 60 actors , just sitting outside the screen waiting to be called on screen, dropped my fps to 35fps. After that I switched to spawn/destroy and gained back those lost fps, but I tell you I'm still getting lags (iPad2/iPhone4s) when I'm spawning my actors, I believe it's due to their animations , the engine needs to load their art to memory and that causes the lag, so bottom line, it depends what actor you spawn, and what assets this actor has, spawning simple bullets should not be an issue, but spawning fire balls from the sky that leaves a particle fire trail, you will see your little test going from 160,000 to 16.
    My game is done and all I'm doing right now is fine tuning what I can while waiting for the new engine to come out, the current engine simply can't handle big games with heavy content, luckily they working hard on the solution.

    Cheers
    Roy.
  • SocksSocks London, UK.Member Posts: 12,822
    . . . but I tell you I'm still getting lags (iPad2/iPhone4s) when I'm spawning my actors . . . // . . . so bottom line, it depends what actor you spawn, and what assets this actor has, spawning simple bullets should not be an issue, but spawning fire balls from the sky that leaves a particle fire trail . . . .
    I think it's important we don't conflate the spawing / destroy method itself with what is being spawned, of course spawning hundreds of fire balls with animations and particles and their own audio (and so on) is going to strain a mobile device but that is a comment on filling your project with hundreds of fire balls with animations and particles and their own audio rather than a comment on spawing itself - the question really is: does spawning and destroying impact on memory / performance any more than recycling with all other things bring equal.


  • POMPOM Member Posts: 2,599
    . . . but I tell you I'm still getting lags (iPad2/iPhone4s) when I'm spawning my actors . . . // . . . so bottom line, it depends what actor you spawn, and what assets this actor has, spawning simple bullets should not be an issue, but spawning fire balls from the sky that leaves a particle fire trail . . . .
    I think it's important we don't conflate the spawing / destroy method itself with what is being spawned, of course spawning hundreds of fire balls with animations and particles and their own audio (and so on) is going to strain a mobile device but that is a comment on filling your project with hundreds of fire balls with animations and particles and their own audio rather than a comment on spawing itself - the question really is: does spawning and destroying impact on memory / performance any more than recycling with all other things bring equal.


    I see what you mean, and I respect it, but my way of working and testing performance is not relying on how the engine handles spawning vs recycling actors just like that, cause in the real world, in an actual game your spawned actors will have assets , and that means you will need to test every situation by itself, sometimes you'll find that spawning actors will cause lags in your game due to the new assets that needs to be loaded, and thus recycling them (while they are already in the scene and their art and code is already loaded into the memory) will reduce that lag significantly.
    What I'm trying to say is that I don't accept the claim to ditch recycling , and it depends on the scene and how heavy it is.

    Sorry if you feel like I'm not on the subject you are asking about, my opinion is that I'm nailing exactly that subject, in a more real life testing, but that's just me.

    Roy.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    . . . I don't accept the claim to ditch recycling . . . .
    Fair enough, we'll have to disagree here, for me on the simple question of whether generating new actors through spawn and destroy impacts performance and memory usage I'd say 'no', loading those actors up with assets that slow performance and reporting that slow performance doesn't say anything about 'spawn and destroy' from what I can see.

    All my tests were 'real life', game elements stripped from my project and the spawning and destroying tested to destruction, running for hours firing off hundreds of thousands of actors in all kinds of scenarios, on an iPad1, iPad3 and iPhone.

    Anyhow, each to their own, every project will have it's own requirements / idiosyncrasies, for me spawing and destroying is a perfectly viable method for generating lots of instances of something (not that there are not situations were recycling actors is useful).
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited December 2012
    Certainly spawning has it's limits as they are not on scene. Things like scene linking X & Y can't be done with spawning. When I have enemies that track the hero I prefer scene linking as it's way faster than external attributes. As with anything in code, just because something works dosen't make it the best code. Building great logic takes planing and thought. I take the time to plan a game in detail and I will even scratch out my code on paper until I get it lean and mean. When you plan this way, you get a sense of the whole and then you can build very integrated code. If you want to know how something is going to perform, do test projects and see. My observation is most new developers are more eger to complete and make a game than learn. Have patience there is no quick easy way to be a GS master. I've been using it for over two years and I learn new stuff and figure out new ways to do things better all the time.
  • sebmat86sebmat86 Member Posts: 339

    This thread is old. But Im glad I found it. This spawning and destroying actors has been a mystery to me. But this thread clears stuff out.

    I do have another question related to this topic. I was wondering how the memory works. If I use spawn/destroy att.s all the time, is the data stored in any way? What happens when I close the game on my phone? Is the data whipped clean, I mean except for tables and att.s that are saved? My game crashes all the time, and lags a lot when I test it on my phone, after I started to use spawn/destroy. Might be something else Im missing. But I was just wonder if it could have something to do with the memory... Do I even make any sense? XD

    /Seb

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @sebmat86, if you have lag and crashing then I would first look at any conflicting rules or runaway spawning.

    Use the "Log Debugging Statement" to track your spawns. It may be that although you only see one actor being spawned, that something in your rules is actually causing multiples of that actor to be spawned in the same place.

  • sebmat86sebmat86 Member Posts: 339
    edited August 2014

    @Hopscotch said:
    sebmat86, if you have lag and crashing then I would first look at any conflicting rules or runaway spawning.

    Use the "Log Debugging Statement" to track your spawns. It may be that although you only see one actor being spawned, that something in your rules is actually causing multiples of that actor to be spawned in the same place.

    Hmm. Yeah. I have checked and made sure there is only one spawn happening. But Ill check out the Log Debugging State. Thanks for the help! :)

Sign In or Register to comment.