Hacker News new | ask | show | jobs
by pmahoney 4834 days ago
"Public service announcement: Object pooling is now a serious performance loss for all but the most heavyweight of objects, and even then it is tricky to get right without introducing concurrency bottlenecks."

  -- Brian Goetz in 2005
http://www.ibm.com/developerworks/java/library/j-jtp09275/in...

This article was also written when Java 6 was starting to get escape analysis, which can result in stack allocations in some cases.

I recall taking a course in 2008 or so (Java 6). We were doing a genetic simulation of sorts, and the professor recommended using an object pool to speed things up. I implemented one and observed no measurable difference in my code's performance (these were very small objects used over and over again evolving new organisms). I hooked up a profiler and used that to guide me to some areas that could be improved, and a valuable lesson was learned.