Recycling vs Spawn/Destroy?
Socks
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.
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
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
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
Cheers RP, useful information. : )
What device are you viewing the spawning+destroy on?
(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)
Can you post the troubled scene (strip out any bit you don't want people to see) ???
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
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.
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
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.
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.
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).
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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
@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.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
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!