Content deleted Content added
m Robot - Moving category Software performance optimization to Software optimization per CFD at Wikipedia:Categories for discussion/Log/2009 September 1. |
No edit summary |
||
Line 3:
Object pooling can offer a significant performance boost in situations where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instances in use at any one time is low. The pooled object is obtained in predictable time when creation of the new objects (especially over network) may take variable time.
However these benefits are mostly true for objects
== Handling of empty pools ==
Line 24:
== Criticism ==
Some publications do not recommend using object pooling with certain languages, such as Java, 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 object allocation is relatively fast in modern languages with [[Garbage collection (computer science)|garbage collectors]]; while the operator "new" needs only 10 instructions, the classic "new" - "delete" pair found in pooling designs requires hundreds of them as it does more complex work. Also, most garbage collectors scan "live" object references, and not the memory that these objects use for their content. This means that any number of "dead" objects without references can be discarded with little cost. In contrast, keeping a large number of "live" but unused objects increases the duration of garbage collection [http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html?ca=dgr-jw22JavaUrbanLegends]. In most cases, programs that use garbage collection instead of directly managing memory actually run faster [http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol23/issue7/spe836.pdf].
== Examples ==
|