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
3
votes
2 answers

Trouble getting a game object from object pool in Unity

I was having trouble converting an object pool script from UnityScript to C#, which I got a lot of good help with here. Now I'm having an issue trying to actually get a game object from the pool. I have three scripts all interacting with one…
user3776884
  • 85
  • 2
  • 7
3
votes
1 answer

cannot access org.apache.commons.pool2.impl.GenericObjectPoolConfig class file for org.apache.commons.pool2.impl.GenericObjectPoolConfig not found

I'm writing a daemon for getting servers stats for some game. In compilation I've get a message: cannot access org.apache.commons.pool2.impl.GenericObjectPoolConfig class file for org.apache.commons.pool2.impl.GenericObjectPoolConfig not found At…
IlyaVorozhbit
  • 78
  • 1
  • 10
3
votes
1 answer

newFixedThreadPool not working as expected with object pool

I'm struggling to figure out how to pool resources and I'm starting to suspect my threads maybe the problem(not 100% but been experimenting with it). The gist of what I'm trying to do is create a pool of channels to a server and then see if threads…
Lostsoul
  • 25,013
  • 48
  • 144
  • 239
2
votes
2 answers

object pooling framework

any suggestions for a C# object pooling framework? requirements are multi-thread support and a pool size limit, when a thread requests an object but none is available, it's blocked until one of the other objects is freed.
Meidan Alon
  • 3,074
  • 7
  • 45
  • 63
2
votes
1 answer

One object pool to contain different derived classes

Short version: How would i go about creating an object pool that can store classes of different types all derived from the same base class? See below for an example of expected usage. Long version: I have a class BaseComponent, with many derived…
George Duckett
  • 31,770
  • 9
  • 95
  • 162
2
votes
1 answer

caching python class instances

I have a memory heavy class, say a type representing a high-resolution resource (ie: media, models, data, etc), that can be instantiated multiple times with identical parameters, such as same filename of the resource loaded multiple times. I'd like…
2
votes
1 answer

Pooling concept in java or EJB?

We have pooling concept in stateless EJB. What is the advantage of using pooling? My understanding is that it will save time in object creation. Is this right? If yes, is there a significant difference in performance in creating the object or…
M Sach
  • 33,416
  • 76
  • 221
  • 314
2
votes
1 answer

remove object out from pool in apache common pool2

I have created GenericPool by extending GenericObjectPool and poolFactory using BasePooledObjectFactory. Now I want to remove the object from my Generic Pool. .clear() will remove idleObject from pool how do we remove permanently from the pool?
2
votes
1 answer

Java - Valid Object Pool with fixed number of Objects to be pooled and use wait-notify

I am trying to implement Object Pool which has fixed number of Objects to be available for pool and using wait if pool if empty and notify when a thread releases an object. I am able to achieve the above required functionality using below program. I…
2
votes
1 answer

Object Pooling implementation ( reusing ) in Unity runner game

I have my first runner game. Everything works fine. So, this question is about optimisation. In my game, There are 15 platforms(road prefabs on which player runs). Randomly out 15 any 1 is instantiated and this keeps happening. When player passes a…
Vineet
  • 47
  • 8
2
votes
1 answer

How we can test the Apache Common pool evict functionality

I am trying to consume Apache common pool library to implement an object pooling for the objects that are expensive to create in my application. For respource pooling I have used the GenericObjectPool class of the library to use the default…
2
votes
1 answer

Which object pool backing store to choose?

In our C# (.NET 4.0) application, we allocate and de-allocate a lot of memory, in different size chunks. We want to move to an object pool, to improve performance. We implemented an object pool already and saw some performance improvement. We're…
SomethingBetter
  • 1,294
  • 3
  • 16
  • 32
2
votes
3 answers

Unity: Need to reset a pooled object on return to pool. Perhaps using ScriptableObject?

I have recently been trying out object pooling in unity to speed up the instantiation of several game objects at once. However, since these are fairly complex objects I need to reset them when they go back in the pool. I read that using…
Adam B
  • 3,662
  • 2
  • 24
  • 33
2
votes
3 answers

Is an Object Pool pattern of shared_ptr possible?

Is it possible to create an Object Pool of shared_ptr? Sketching this in my head, I can see two ways of doing this but each have a flaw: If T objects were stored in a reusable pool, the act of wrapping T in a shared_ptr on a get() request would…
Nicholas
  • 1,392
  • 16
  • 38
2
votes
0 answers

Optimize Scroll list on Unity

I'm quite new to Unity. I'm making GUI on Unity and having trouble with the scroll list. I have a prefab of list item. Besides, I get data of around 100 items from server, saved in a List. Now, if a populated data into the Scroll view as normal, I…
Brian Pham
  • 551
  • 9
  • 23
1 2
3
11 12