x


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.

more ▼

asked Dec 06 '11 at 08:01 PM

htaunay gravatar image

htaunay
220 7 9 11

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 minor 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 instead of using unity's instantiate and destroy.

Dec 06 '11 at 10:03 PM dannyskim

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.

Dec 06 '11 at 10:33 PM WillTAtl
(comments are locked)
10|3000 characters needed characters left

0 answers: sort oldest
Be the first one to answer this question
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x762
x660
x132
x77
x24

asked: Dec 06 '11 at 08:01 PM

Seen: 667 times

Last Updated: Dec 07 '11 at 01:37 AM