Application.GarbageCollectUnusedAssets()

I understand that calling this will just “hint” to the garbage collector to do a cleanup, but it is up to the OS to decide when to do this… so is there any penalty in calling it more often than not?

For instance, in circuit defenders, I have GO’s being instantiated and destroyed all the time, in an on going basis. Is there any hard for me to call…

Application.GarbageCollectUnusedAssets();

every 10 waves in my game?

Also, is there any equivalent in Unity 2.1 ?

i´m not sure if its exactly that way with unity stuff on the iphone but in pretty much all other environments/languages/technologies i worked with triggering a garbage collector call should ideally be done in pretty much idle moments, not when constant fps/performance is required like in midgame situations (the reason is that a garbage collector sweep round can lead to fps drop for a while next to other things).
So yeah, ideally i´d suggest you do it when changing scenes, the game is paused or in menu screens etc, not regularly while your gameplay is going on.

Also i´d suggest reusing the same objects as much as possible instead of constantly creating new ones and destroying the old ones.

Well, that´s my suggestions coming from experience with game dev with other technologies, maybe someone with more experience than me regarding the unity tech side can correct me if what i said is nonsense with unity :slight_smile:

To my understanding that calls main usage is to clean after a level / scene has finished. That for example could be at the beginning of the loading screen of a new level, in a TD like game in the waves / levels “how you performed” overview screen and alike.

If you are heaving a fulltime action game you might be better off ensuring that the stuff is destroyed directly when its not needed anymore.