Mike018 Posted October 25, 2017 Share Posted October 25, 2017 How many objects before a state change should you start considering using an object pool? Now I don't break 50 with a single type of object, so I haven't bothered, but I'm curious about when it will start having any signs of performance issues. 100? 500? Link to comment Share on other sites More sharing options...
mattstyles Posted October 25, 2017 Share Posted October 25, 2017 If you have a way of measuring performance then create a test that keeps adding objects and see how many before perf starts seeing dips or degrading, true degradation is unlikely but you might see spikes as the GC kicks in to do its things. If you can't measure perf yet then wait until you can, this is really an optimisation and optimisations are pointless without a means of testing the impact of those implementations. Note that any tests you make are likely to be imperfect but run them enough times and you should start to see some trends, maybe. Also note that its likely impossible you can test on all of the devices your app might run on, so take test results with a pinch of salt, hence the next point. Many people take the approach that if your list is continually (or regularly) adding elements and you're forcing a quick refresh draw (which you almost certainly are) then, at some point, you will hit some limits so they start implementing object pooling immediately i.e. before measuring and optimisations. It's not a bad assumption to make and could well save some pain later as implementing object pooling isn't always straight forward. gauravD 1 Link to comment Share on other sites More sharing options...
Recommended Posts