Content deleted Content added
Line 22:
If the pool is used by multiple threads, it must have means to prevent parallel threads from grabbing and trying to reuse the same object in parallel.
== Critisicm ==
Some publications do not recommend to use object pooling, especially for objects that only use memory and hold no external resources [[http://www.ibm.com/developerworks/java/library/j-jtp11253/]. Opponents usually say that with modern languages the cost of allocating an object is not high. Also, the most of garbage collectors scan "live" object references and not the memory that these objects use for they content. This means that any number of "dead" objects without references can be discarded with the little cost. Differently, keeping the large number of "live" but unused objects increases duration of the garbage collection [[http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html?ca=dgr-jw22JavaUrbanLegends]]. Some works demonstrate that removal of the direct memory management (putting the garbage collector instead) in the most cases actually make programs to run faster.
== Examples ==
|