Skip to content

Files

Latest commit

1c0e0cd · Mar 31, 2018

History

History
This branch is 2265 commits behind iluwatar/java-design-patterns:master.

object-pool

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 28, 2017
Dec 31, 2017
Nov 28, 2017
Mar 31, 2018
layout title folder permalink categories tags
pattern
Object Pool
object-pool
/patterns/object-pool/
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)