Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 hawks001 · Feb 09, 2017 at 02:15 AM · performance optimizationmemory managementobject pool

When to use object pooling ?

Hi, I have a little confusion about usage of object pooling. Actually in some scenario I can not decide whether I should use object pooling or not. For example I have made a 2D game in which a 2D fruit object moves on screen and I have to hit it with arrow sprite and when they collides with each other they become destroyed and new object of fruit and arrow is created and game is infinity .So in this scenario I have pooled all the fruit objects and arrow objects but the point which is confusing me is that arrow and fruit stays alive for 2 to 5 seconds on screen and at a time its one fruit and one arrow on screen so what's the need of keeping memory. So what is better in this scenario object pooling or create destroy strategy? I am making this game for IOS and Android devices and one thing more that my objects have lot of initialization in start method.

Comment
Add comment · Show 1
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 elenzil · Feb 09, 2017 at 05:13 AM 1
Share

don't optimize stuff unless there's a problem.

the scenario you're describing sounds pretty chill.

i wouldn't consider bringing in object pooling until you're churning through say more than 100 creates/destroys per second.

the places where i've seen object pooling have a real impact is when there's tens or hundreds of thousands of objects per second.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by James2Games · Feb 09, 2017 at 05:36 AM

To quote a unity developer from a youtube tutorial on optimization.

"Use the profiler before you optimize"

If your game is running slow in the main menu but not in the game. Why optomize the game?

As @elenzil mentioned above. Object pooling is only useful when there are a lot of objects being created and destroyed and is causing heavy changes in the fps. Where as pooling a handful of small objects will speed up the game by maybe a few milliseconds but at the cost of keeping that memory always at bay and cluttering your code.

If you are unsure if you should pool something then most of the time it will be a no. If you think it should be pooled, then take a look at the profiler and see if there's much heavy usage coming from Instantiate or Destroy and make your decision there.

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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Object's Rotation Acting Weird After Being Re-used From Object Pool 0 Answers

Importing Hard Edges without increasing polycount. 1 Answer

Most efficient way of pausing a function 0 Answers

Many 2048x2048 Spritesheets vs A Single 4096x4096 Spritesheet 0 Answers

Low Poly Alpha Cutout vs Full Models Performance 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges