Questions tagged [objectpool]
30 questions
30
votes
3 answers
BlockingCollection(T) performance
For a while at my company we've used a home-grown ObjectPool implementation that provides blocking access to its contents. It's pretty straightforward: a Queue, an object to lock on, and an AutoResetEvent to signal to a "borrowing" thread when…

Dan Tao
- 125,917
- 54
- 300
- 447
24
votes
3 answers
Flyweight vs object pool patterns: When is each useful?
As far as I know the object pool is a creational pattern and the flyweight is a structural pattern, but actually I can´t see very much difference between the two. Could someone please explain to me the difference and when each could be useful in an…

edgar9000
- 241
- 2
- 3
21
votes
12 answers
How do you make your Java application memory efficient?
How do you optimize the heap size usage of an application that has a lot (millions) of long-lived objects? (big cache, loading lots of records from a db)
Use the right data type
Avoid java.lang.String to represent other data types
Avoid…

Boune
- 1,063
- 2
- 10
- 15
8
votes
1 answer
How to avoid heap fragmentation in iOS
Our app creates alot of small objects while running. It mostly comes down to Autoreleased NSString and NSNumber objects. Since the app is designed to run "24/7" in the background heap fragmentation becomes a big issues.
What are the techniques to…

pkuhar
- 581
- 6
- 17
8
votes
1 answer
scala-way for managing object pools
What is the preferred way in scala for managing object pools?
I need to create and delete large scale of objects single-threaded (no need for synchronization) . In c++ I've used array of static objects.
What is idiomatic and effective way to cope…

ayvango
- 5,867
- 3
- 34
- 73
7
votes
1 answer
Boost Pool experience requested. Is it useful as allocator with preallocation?
Recently i have been looking for a pool/allocator mechanism.
Boost Pool seems to provide the solution, but there is still things, which it have not been able to deduce from the documentation.
What need to be allocated
Several small classes (~30…

Steffen Villadsen
- 81
- 2
- 7
5
votes
3 answers
C++ Lock-Free templated ObjectPool
do they exist ?
*added to clarify:
is there any usable library that implement lock-free (which is threadsafe and might be implement spinlock or other lightweight synchronization) ObjectPool ( http://en.wikipedia.org/wiki/Object_pool_pattern )…

uray
- 11,254
- 13
- 54
- 74
4
votes
2 answers
Is there any generics version of apache common object pool?
When using apache common pool, it can provide me a good implementation of Java object pooling. However their KeyedPoolableObjectFactory interface is not type safe. Is there any object pool library in Java that can provide a generics interface for us…

raymond.mh.ng
- 343
- 2
- 3
- 21
4
votes
1 answer
Clarification on the "object pool" pattern?
I was under the impression that an object pool is a design pattern used for managing a group of pre-allocated objects to which a client can request and be returned one of these objects. However, it seems that boost.pool's object_pool class has more…

jwalk
- 1,120
- 11
- 27
3
votes
1 answer
Is GenericObjectPools borrowObject Method thread safe?
In this question Is GenericObjectPool from commons.apache.org thread safe? It is mentioned that its thread safe .
Edited:But im having a situation in my multithreaded application that two threads are getting the same object from the pool at…

Bijesh CHandran
- 477
- 1
- 8
- 22
3
votes
3 answers
When to return an object back to its pool
I want to use an object-pool in my C# application, and I know that there isn't any reference count in C#. If the same object can be passed to several threads, how can I know when there are no more references to the object so that I can return it to…

gerstla
- 587
- 1
- 5
- 20
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…

springcloudlearner
- 457
- 3
- 20
1
vote
2 answers
How can I prevent construction with Object Pool
I want to use the Object Pool design pattern for my library, so that the user cannot create more than a predefined number of objects.
How can I force the user to use the Pool class for acquiring an instance, instead of constructor of the resource?
I…

randomVariable
- 305
- 1
- 4
- 12
1
vote
0 answers
Pointer comparison issue during implementing of "Small-Object Allocator" from Modern C++ design
Memory deallocation is more problematic, because at deallocation time
there's a piece of information missing—all we have is a pointer to
deallocate, and we don't know to what Chunk that pointer belongs. We
can walk through chunks_ and check…

felix
- 2,213
- 7
- 16
1
vote
2 answers
Objectpool vs. immutable Objects
Say you are working with a simple class and object creation is not heavy:
class Simple {
public final int data1;
public final float data2;
...
}
You have to continuously put simple-objects into a queue:
queue.add(new…

testo
- 1,052
- 2
- 8
- 24