I have a question about ram, cpu usage. Is inactive object use cpu or ram effective? Should am I destroy objects when change level with prefab system?
In general, I’ve found that inactive objects have very little impact on performance. It’s very common to have an object pooling system where you reload a large number of objects when the scene loads, deactivate them all, and then activate each one at a time as needed. It’s certainly possible for inactive objects to cause performance problems in certain cases, but I’d say those are rare exceptions. So, in general, unless you’re seeing specific bad performance via the Profiler, I think deactivating is probably good enough. While it’s inactive, it’s still hanging on to some memory, but I think it should barely register on the CPU side of things.
However, if you’re really not going to use an object again, may as well destroy it to fully free up its resources. Again, let the Profiler guide you on that sort of thing.
Thank you so much for reply yeah i dont use them again.
Inactive objects do remain in memory, but if you are going to use the same type of objects over-and-over in a game (like bullets in a shooting game, example) it’s usually a lot more efficient to create a group of objects (of the same type) at the beginning and reuse them, rather than constantly delete and re-create the same objects continually.
This type of group is usually called a “pool” and the technique is called “object pooling”.