Instantiate and Destroy vs Object pool

Hi All,

I want to know something about performance in Unity games. I have a game where some objects (rather large number) appear in the screen, move somewhere and then disappear when they are beyond the screen.

First, I may use Instantiate to create them and then Destroy to remove them when they are away. Is it good for performance?

Is it worth to use pools? I mean to have about 50-100 ready objects, take them from the pool if there are some ready to be used (beyond the screen already), or Instantiate a new one if there are no ready objects.

Has anyone checked performance? Maybe someone has compared these two ways already.

In my book (Object Pool) > (Basic Instantiate) especially for objects that have a rapid create / destroy sequence.
They’re straight forward / quick to setup so you’d be able to test your specific implementation from code based on the pooler on the wiki.
Will it make a diff for you? Likely.

Sorry, I couldn’t understand your post. Do you mean pools are better? Or vice versa?

I think it may cause a problem on mobile devices. So I want to choose a better way.

Hi!
In my experience, pools are better, especially for mobile platform.

Thanks! I thought that, but was in doubt, maybe Unity is optimized… So will try to make pools.

Instantiation and destroying are heavy operations, it takes a lot of time on mobile devices, so pools are definitely better in some cases, e.g for often spawning bullets.
From personal experience, my mobile game framerate improved a lot when I added object pooling for enemies and bullets.

Sorry if my shorthand confused you. Yes pools are generally better than raw instantiation. i.e. greater than.

Thank you all, guys! That’s exactly what I wanted to know :slight_smile: