Questions tagged [object-pooling]

The object pool pattern is a software creational design pattern that uses a set of initialized objects kept ready to use – a "pool" – rather than allocating and destroying them on demand.

The object pool pattern is a software creational design pattern that uses a set of initialized objects kept ready to use – a "pool" – rather than allocating and destroying them on demand. A client of the pool will request an object from the pool and perform operations on the returned object. When the client has finished, it returns the object to the pool rather than destroying it; this can be done manually or automatically.

Object pools are primarily used for performance: in some circumstances, object pools significantly improve performance. Object pools complicate object lifetime, as objects obtained from and return to a pool are not actually created or destroyed at this time, and thus require care in implementation.

Object pooling can offer a significant performance boost in situations where the cost of initializing a class instance is high and the rate of instantiation and destruction of a class is high – in this case objects can frequently be reused, and each reuse saves a significant amount of time. Object pooling requires resources – memory and possibly other resources, such as network sockets, and thus it is preferable that the number of instances in use at any one time is low, but this is not required.

http://en.wikipedia.org/wiki/Object_pool_pattern

171 questions
0
votes
1 answer

Unity C# list being cleared when the method is complete - object pool

I am trying to make a simple object pool in c# for Unity. So far I have used this class: using UnityEngine; using System.Collections; using System.Collections.Generic; public class ObjectPool : MonoBehaviour { public static ObjectPool…
hinch
  • 91
  • 2
  • 12
0
votes
2 answers

Apache Pool 2 - predefined object instances with fixed capacity

I would like to use Apache Pool 2 library, but looking for following functionality: The objects are not dummy new empty instances, but pre-loaded objects from external data source. You can imagine each object is unique working configuration which…
kensai
  • 943
  • 9
  • 16
0
votes
1 answer

How to decrease the constructor overhead by automatic acquisition and release from an object pool?

I have created an immutable data type in Python where millions of objects are created and released every second. After profiling the code thoroughly, it looks like the constructor is where most of the time is spent. The solution I thought of was to…
Matt
  • 796
  • 12
  • 25
0
votes
1 answer

Object pool and flash

When is it a good idea to use an object pool in Flash? For example, is it a good/bad idea with bitmaps, MovieClips (with timeline animations inside of them), video, fonts?
redconservatory
  • 21,438
  • 40
  • 120
  • 189
0
votes
1 answer

Keyed object pool not keeping minimum number of idle objects in pool at all times

An application I'm working on, uses the Apache Commons library to implement the KeyedObjectPools. We have an Object factory, wherein we have implemented the methods specified in the KeyedPoolObjectFactory interface. The implementation looks like…
0
votes
1 answer

What alternative to C++ vector when it comes to fast deletion?

vector is the first choice in many situations because random access is O(1), as there are not many containers that are fast enough, or at least O(log(n)). My issue with vector being that vector<>::erase() is O(n), map<>::erase() is faster and is a…
jokoon
  • 6,207
  • 11
  • 48
  • 85
0
votes
2 answers

Javascript GC apply existing object

Suppose we have a pool of objects (aka an array). Then we Constructor.apply(obj, arguments). var obj = objectPool[nextAvailableIndex]; obj.index = nextAvailableIndex; nextAvailableIndex += 1; Constructor.apply(obj, arguments); …
FreddyNoNose
  • 478
  • 1
  • 7
  • 13
0
votes
2 answers

Unity 5 2DArray, Object pooling

Im trying to make a object pooling system for my WaveSpawner. This is what I got (objectPool is a 2D array): objectPool = new GameObject[wave.Length,0]; //set columns for(int i = 0;i< objectPool.Length;i++) { objectPool = new…
user7183273
0
votes
1 answer

Can spring boot applications deployed on a tomcat server use a common connection pooling?

When multiple spring boot applications created and deployed to a tomcat server. Is it possible to use a common connection pooling, datasource instead of providing these details in application.properties file. Or does this already taken care within…
0
votes
3 answers

Akka actor message needs memory pool

I a new in java. I'm c++ programmer and nowadays study java for 2 months. Sorry for my pool English. I have a question that if it needs memory pool or object pool for Akka actor model. I think if i send some message from one actor to one of the…
Kebron
  • 23
  • 4
0
votes
2 answers

Cleaning object pool based on execution time

Problem My current project implements a pool of objects to avoid constant memory allocation and de-allocation for speed purposes, the object pool is a std::vector and I would like to implement a form of garbage collection to reduce memory…
nitronoid
  • 1,459
  • 11
  • 26
0
votes
1 answer

Best way to create a object pool if objects needs to load the same huge file for initialization

Does someone know a good way to create a pool of objects containing really heavyweight objects? I already tried it and it works so far, but my problem is, that each object needs to load the same huge model file for initialization (~200MB), so the…
bunzJ
  • 3
  • 2
0
votes
1 answer

Object pooling in C# throwing StackoverFlow Exception

I am trying to implement object pooling in C#. My requirement is to have a pool which can hold 100 active SqlConnection objects. If the pool is already having 100 connections and if user requests a new connection, then pool has to wait till one…
0
votes
2 answers

Unity 5 - Object pooling not deactivating objects

I'm working on an endless runner game. I'm very much a beginner to programming, working off this and this tutorial, so I'm not 100% sure how this code works, which makes it difficult to figure out how to fix my problems. The code is supposed to use…
MayorDump
  • 13
  • 1
  • 4
0
votes
1 answer

Dispose objects in a pool

What is the proper way of disposing objects that are in a pool? I have a pool with ParticleEffects and I guess they need to be disposed. So when should I do that? I don't think it is a good idea to dispose that ParticleEffects when I put them back…
Zezi Reeds
  • 1,286
  • 1
  • 16
  • 29