- Home /
Destroy gameobject or make invisible and recycle?
which one is more efficient memory wise in unity, should i make the object invisible and recyle it to a new position when needed, or just destroy and add a new one at run time when needed?
Answer by sparkzbarca · Nov 11, 2012 at 01:23 AM
destruction requires more memory management overhead. making invisible requires more gpu management overhead to cull and everything.
MOST LIKELY destroy is better, the whole time its invisible its probably causing overhead to keep it that way and run checks on it to see if its changed etc.
having 1k invisible objects probably causes alot of over head over time.
having 1k destroy calls might hiccup a game which can be bad as well even if short term its actually more noticable than a smaller constant slowness.
if its not that common honestly it probably doesnt matter either way.
but basically Destroy causes memory overhead to both destory and then allocate new memory which was pointless because really you could have just kept that empty memory.
Invisible is pointless because you dont want it to be invisible, you want it to not exist and ihvisibile is more overhead than not existing.
Pick your poison by which is more convienent I say. Honestly your probably not doing enough calls either way to really matter.
I mean an object