• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by tddaniels · Nov 28, 2014 at 05:35 AM · instantiatemobiledestroygameobjectspool

Pooling everything...or not?

I've got a mobile game that I'm building a pool of all game objects to be used when the game is loaded (currently 147 different objects). The objects are all set to be persistent. Before I just built the pool at the start of the level (so less objects were created, then stored, and finally destroyed each level). I'm wondering if anyone sees any potential problems with this approach or has tried something similar.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image taxvi · Nov 28, 2014 at 06:58 AM 0
Share

I'd do that only if my framerate was lagging (because I don't like experimenting with things if I don't absolutely have to, it's just me) and if I needed to save cpu power, but other than that, nah. Though it's a good experience.

avatar image tddaniels · Nov 29, 2014 at 11:40 PM 0
Share

I think I'll take your advice. It quickly becomes a pain trying to manage persistent objects that have differing tasks per level.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Kiwasi · Nov 30, 2014 at 12:13 AM

Pooling really depends. The advantages of pooling are

  • You only load once

  • You avoid unpredictable garbage collection

Disadvantages

  • A little more code to set up

  • Unused objects remain in memory. This can cause problems on memory limited platforms. Especially if there are large spikes in the number of pooled objects

Ultimately pooling should be used when you have a large number of identical objects being frequently instantiated and destroyed. Bullets are a classic example. Obstacles in a infinite runner and enimies in a space shooter are other good candidates.

You shouldn't use pooling for unique objects, or objects that are never destroyed. Players in a FPS or unique boss monsters are good examples.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sudden frame rate drops on mobile when instantiating/destroying? 1 Answer

How do you use a pool of objects rather than creating and destroying repeatedly? 8 Answers

Pooling object performs the same or worse than instantiate/destroy? 1 Answer

Instantiate and Destroy optimization 1 Answer

Firing only a single projectile at a time, then adding a second. 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges