phpearth / docs

🎓 Collection of useful PHP frequently asked questions, articles and best practices
https://docs.php.earth
Other
286 stars 127 forks source link

Explain how the object pool can improve performance #305

Open petk opened 6 years ago

petk commented 6 years ago

https://php.earth/docs/php/ref/oop/design-patterns/object-pool

0xcrypto commented 6 years ago

At https://sourcemaking.com/design_patterns/object_pool I read, "The Object Pool lets others "check out" objects from its pool, when those objects are no longer needed by their processes, they are returned to the pool in order to be reused.

However, we don't want a process to have to wait for a particular object to be released, so the Object Pool also instantiates new objects as they are required, but must also implement a facility to clean up unused objects periodically."