2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Object Pool
|
|
|
|
folder: object-pool
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/object-pool/
|
2015-08-16 17:07:36 +05:30
|
|
|
categories: creational
|
2015-08-13 23:54:40 +02:00
|
|
|
tags: pattern_tag
|
|
|
|
---
|
|
|
|
|
|
|
|
**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.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
**Applicability:** Use the Object Pool pattern when
|
|
|
|
|
|
|
|
* the objects are expensive to create (allocation cost)
|
2015-08-15 18:03:05 +02:00
|
|
|
* you need a large number of short-lived objects (memory fragmentation)
|