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

Third party lib for object pool with expiration time in Java

I'm on a webservice server and I have objects with an internal connection. Initializing this connection takes really long so my idea was to use an object pool to reuse the connections among different requests. The objects are connected to each…
Sorontur
  • 500
  • 4
  • 15
5
votes
1 answer

Any clonable object pool implementation in C or C++?

This may seem odd, but I'll try to rationalize it. I currently use boost.object_pool extensively in conjunction with shared_ptr, and recently I encountered a situation that I need to take snapshots of current program states, in order to make…
arch.jslin
  • 81
  • 4
4
votes
3 answers

PHP pooling functionality (not just database connections)

Is it possible to pool data or functionality in PHP? The amateur-ish PHP code that I write wakes up to handle a response, loads functions, opens database connections, create objects, initialises them, and then - dies after 0.01 secs when the…
boisvert
  • 3,679
  • 2
  • 27
  • 53
4
votes
1 answer

How can I implement a reusable object pool in C#?

I'm processing a lot of data off a streaming socket. The data is used and left for the GC to clean up. I want to allocate a reuseable pool upfront and reuse it to prevent lots of GCs. Can anyone help me?
arkina
  • 991
  • 2
  • 11
  • 17
4
votes
2 answers

Supply Long Object Pool to Jackson Object Mapper

I have a JSON that I convert into POJOs. The JSON is read from a GZIPInputStream gis. ObjectMapper mapper = new ObjectMapper(); TypeReference> typeRef = new TypeReference
Pranav Kapoor
  • 1,171
  • 3
  • 13
  • 32
4
votes
2 answers

Pooling Maps in Golang

I was curious if anyone has tried to pool maps in Go before? I've read about pooling buffers previously, and I was wondering if by similar reasoning it could make sense to pool maps if one has to create and destroy them frequently or if there was…
jeromefroe
  • 1,345
  • 12
  • 19
4
votes
3 answers

Java - ThreadLocal or Concurrent Object Pool?

Which method is more acceptable to access to a Non Thread Safe Object ? using ThreadLocal objects : static final ThreadLocal PARSER_THREAD_LOCAL = new ThreadLocal() { @Override protected…
FaNaJ
  • 1,329
  • 1
  • 16
  • 39
4
votes
1 answer

3D infinite runner game platform generation gives an exception

Situation: I am referring to tutorial for my project,and there is an object pooling concept within the code. Problem: What happens is , after I scripting the generation platform(PlatformManager.cs), I get an exceptions…
AVI
  • 5,516
  • 5
  • 29
  • 38
4
votes
2 answers

Object pool pattern - separation of concerns - encapsulation: Who is responsible for deleting an instance?

Situation During a development I implemented the design pattern called object-pool-pattern. Basically this means that our class has a static public method and a static-protected attribute. This attribute carries all instances, which can be retrieved…
icbytes
  • 1,831
  • 1
  • 17
  • 27
4
votes
2 answers

What level of locking granularity is good in concurrent data structures?

I am quite new to multi-threading, I have a single threaded data analysis app that has a good bit of potential for parallelization and while the data sets are large it does not come close to saturating the hard-disk read/write so I figure I should…
James Matta
  • 1,562
  • 16
  • 37
4
votes
3 answers

How to create custom object pools in Java application server

Suppose I have a message driven bean (MDB) in a Java application server. The MDB receives a message from a JMS queue and passes it to a message processor. In my case, a message processor is an extremely heavy weight object that requires extensive…
Dave Ray
  • 39,616
  • 7
  • 83
  • 82
4
votes
2 answers

Stack or LinkedList for ObjectPool?

I'm sure the correct answer to this depends on the type of pooled objects and the workload, so I'll detail my implementation a bit: I have an ObjectPool used to pool long-running command-line processes. These processes communicate via stdin/stdout,…
Will
  • 24,082
  • 14
  • 97
  • 108
3
votes
2 answers

Creating a generic class pool where you give the generic parameter and get a generic object that used that parameter

Goal I have a generic class GenericClass and I want to pool instances. I'm interested in seeing if I can get the syntax: MyGenericPool = new GenericPool(); // Or maybe it's MyGenericPool = new…
George Duckett
  • 31,770
  • 9
  • 95
  • 162
3
votes
2 answers

Most efficient way to set all fields of a class to default value

I'm trying to create an object pooling framework. Every time a client requests an objects of some type, I return an object from a cache (a queue) or create a new object if there isn't any in the cache. Now when the client code is done with the…
morteza khosravi
  • 1,599
  • 1
  • 20
  • 36
3
votes
1 answer

boost object_pool construct method

I'm keen on using boost's object_pool class for memory re-use for a set of video frames. boost::object_pool< VideoFrame > FramePool; Now, the VideoFrame class has two constructors. The first version of the constructor takes 4 arguments while the…
ZeroDefect
  • 663
  • 1
  • 8
  • 27
1
2
3
11 12