象池很多时候是很有用的模式,有时甚至是必须。但凡事过犹不及,对象池也只有在一些场景下才适合。
|
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 which are expensive with respect to time, such as database connections, socket connections, threads and large graphic objects like fonts or bitmaps. In certain situations, simple object pooling (which hold no external resources, but only occupy memory) may not be efficient and could decrease performance. |
引用自:
http://en.wikipedia.org/wiki/Object_pool_pattern
References
http://www.ibm.com/developerworks/java/library/j-jtp09275/index.html
转自:http://vaporz.blog.51cto.com/3142258/706945
本文探讨了对象池模式的使用场景及优势,特别是在初始化成本高、实例化频率高且同时使用的实例数量较少的情况下。该模式有助于提升性能,尤其是在处理如数据库连接、套接字连接等昂贵资源时。
661

被折叠的 条评论
为什么被折叠?



