Sign in to follow this  
Mike018

at what point should you implement object pools?

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.