Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by htaunay · Dec 06, 2011 at 08:01 PM · performancedestroymonobehaviouraddcomponentlimitations

Is there such thing as a recommended Component cap?

This is more of a conscious check due to some performance issues my team has been encountering.

Is there by any chance a recommended cap for the number of Components/MonoBehaviours that can be created (through AddComponent()) and removed (through Destroy()) every FixedUpdate? Of course, I am not considering the obvious "the more objects created/destroyed, the less performance". I just wanna make sure I am not getting stuck in a pipeline that i am not aware of, or if there are any good Unity practices on such subject that I could learn (besides the also obvious "the less possible objects, the better").

Thanks in advance.

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 dannyskim · Dec 06, 2011 at 10:03 PM 2
Share

Well from my very short experience on mobile platforms, even with 15 fairly simple draw calls on the scene without optimization, destroy and instantiating prefabs has caused $$anonymous$$or hiccups in frame rate and slight pauses that definitely shouldn't be there.

I've added and removed primitive components without too many issues. When it comes to allocating memory with prefabs though, I definitely would recommend some form of object pool that is initialized and recycled ins$$anonymous$$d of using unity's instantiate and destroy.

avatar image WillTAtl · Dec 06, 2011 at 10:33 PM 2
Share

dunno about rule-of-thumb limits on how often, but where possible, you might try disabling and enabling components rather than adding and destroying them; this would avoid any alloc/dealloc costs involved.

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Clearing a LineRenderer Whiteboard, so that you can start drawing again 1 Answer

Difference between capitalized component in AddComponent and Destroy 2 Answers

Best approach for a distance based destroyer 1 Answer

Can't add component because class doesnt exist 1 Answer

Would abuse of inheriting from extended MonoBehaviour hurt the 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