Inactive object memory load.

Over the course of my mobile game potentially hundreds of inactive objects could be generated. The game is rather physics intensive with up to 16 2d rigidbodies. I have optimized the code so it runs reasonably well on lower end phones but not with a large amount of inactive objects. Would hundreds of inactive objects affect my performance by taking up memory on a weaker phone like the iphone 4?

Bonus question, if it does take up memory I want to implement some garbage collection to delete the inactive objects. I’ve been having trouble setting up references when the objects become inactive. Any insight on how to set it up? i’ve been following this but i’m getting lots of compatiblity errors setting up the array. Cannot toggle active on gameobjects that are inactive - Unity Answers

Thanks

Just a heads up, Unity’s garbage collection actually has a decent overhead, so you want to avoid garbage collection as much as possible. In terms of optimization, are you recycling objects so that you don’t have to call Instantiate and destroy? When I code my mobile games, every time an object has finished its assigned task, such as a platform for a 2D platformer moves off screen, I disable it and add it to a stack to be reused when necessary. This way I use minimal Instantiate and Destroy calls, which keeps Unity from initiating garbage collection, and keeps the total number of objects in my scene relatively small.