Ilkka Seppälä 9ec0935a1c Merge pull request from leogtzr/master
Adding initialization-on-demand idiom and noninstantiable class instead of interface constant idiom
2017-01-23 08:21:07 +02:00
..

layout, title, folder, permalink, pumlid, categories, tags
layout title folder permalink pumlid categories tags
pattern Object Pool object-pool /patterns/object-pool/ JSV94SCm2030Lk829Fxf1cF6bWU1XYDkFtdcjxiD9Qc3o-LrPQvu0pW-_HnvrLx1JgR9cfrimf1wCD7XnW-sWsESsXPcicl0nFW1RB-PiYqp0KxwVo-VVTMKBm00 Creational
Java
Difficulty-Beginner
Performance

Intent

When objects are expensive to create and they are needed only for short periods of time it is advantageous to utilize the Object Pool pattern. The Object Pool provides a cache for instantiated objects tracking which ones are in use and which are available.

alt text

Applicability

Use the Object Pool pattern when

  • the objects are expensive to create (allocation cost)
  • you need a large number of short-lived objects (memory fragmentation)