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

Eliminate abruptly closed sockets from the pool, Java

Assume there is a Java implementation of Object Pool and the objects are successfully connected TCP Sockets. I keep a "Clean-Up" thread at the Pool level (ConnectionFactory) that checks every N mins that whether the pool is being idle for some M…
Kana
  • 21
  • 3
0
votes
2 answers

(Unity) Trying to convert an object pool script from UnityScript to C#- stuck on an error

I found a great object pooling script but it's in UnityScript and my project is in C#. I've been trying to convert it but I'm stuck on one error that I don't quite understand. Here is my script: using UnityEngine; using System.Collections; using…
user3776884
  • 85
  • 2
  • 7
0
votes
1 answer

Task Parallel Library and Object pool design pattern

I have a scenario like where I am using Task Parallel Library and I need to restrict the number of objects (here tasks) created. That means it will reuse the existing task and I am thinking of using Object pool design pattern to implement this…
Dev
  • 309
  • 1
  • 8
  • 24
0
votes
1 answer

Object pool with the ability save objects on exit and reload on start?

Apache Commons seems to be the decent Object Pool implementation out there. Or any other framework that could support the cause How Can I save its state of the pool during shutdown; may be serialize its objects to a external form json, xml ..? and…
Njax3SmmM2x2a0Zf7Hpd
  • 1,354
  • 4
  • 22
  • 44
0
votes
0 answers

is this the only way i can use object pools?

I've been looking into using Apache common pool for an android game im working on, however it seems object pooling doesn't work for generic classes. So i believe i am left with two options for pooling. I make every game object generic but alter…
Christopher Lawless
  • 1,057
  • 2
  • 12
  • 19
0
votes
1 answer

On being Invoked by KeyPress, my gameobject appears alright, but does not get invoked again on key press?

I was instantiating and destroying my gameobjects earlier but on learning that it is processor intensive, manipulated my code so that it is an object pool of 1 object. When I press Z, my object gets activated and starts scaling bigger as long as Z…
0
votes
2 answers

Object pools to handle ImageViews in Android?

In my Android app I created a View showing a field of 9x9 (see simplified screenshot): Each field in the view is represented by an ImageView (showing pictures instead of rectangles). Some ImageViews will be deleted by setting them to null and…
jimmyp.smith
  • 178
  • 6
0
votes
1 answer

Reuse Box2D objects in LibGDX game (pooling)

I'm working in a game in which I spawn an object every 1-3 seconds. This game object contains some assets for renderization purposes and a Box2D body. The thing is that I don't want to create thousands of objects. Instead, I would like to reuse…
David Moreno García
  • 4,423
  • 8
  • 49
  • 82
0
votes
1 answer

How to Object pool for event Listeners in Java or JavaScript

I been reading articles about how object pooling reduces the garbage collection for games, especially for event listeners where the key event is constantly being created and destroyed. They mention how object pooling would decrease the memory…
user3213315
0
votes
1 answer

Passing objects from a pool to a runnable class

I have an pool of objects in a blockingQueue. Now i want to assign objects from the queue to a thread and use it inside the run method. What is the best way of doing it? Here is a sample code i am using to build the pool: public class ConsumerPool…
Nischal Hp
  • 435
  • 1
  • 6
  • 21
0
votes
2 answers

Is putting the object back to the pool mandatory?

I am using Apache's GenericObjectPool to create the pool of objects of my class. I have web application. Once my request is processed, I am putting the the object back to the pool without any issues. In the code i am keeping the object back to the…
user755806
  • 6,565
  • 27
  • 106
  • 153
0
votes
1 answer

boost::object_pool on custom memory heap

I would like to create an object pool but I want it to allocate memory on only a specific segment of my memory heap. Is there any way to do so using boost ?
w00d
  • 5,416
  • 12
  • 53
  • 85
0
votes
1 answer

Object pool - creating the objects later isnt working

My aim is to create a vector containing many pre-prepared (I dont have the two data members until later on but I want to allocate as much as I can in continuous memory) instances of my object in continuous memory and then later on in my program I…
user997112
  • 29,025
  • 43
  • 182
  • 361
0
votes
1 answer

Creating an object pool

I'd like to create an object bool using a vector of type X objects. When I create the vector: vector* v = new vector; v.reserve(10000); I want the minimal work done as possible. Will just the default constructor get called (my default…
user997112
  • 29,025
  • 43
  • 182
  • 361
0
votes
1 answer

Pool the JAXWS wsimport service object - possible?

we are using JAXWS metro client to interface with a 3rd Party .Net web service. We need to maintain state with the web service. So, here's the scenario. There are several user applications that would invoke the metro client which in turn invokes…
1 2 3
11
12