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

static final String = "something" -- does the static make sense?

static final String = "something"; I was wondering if such a declaration has some kind real sense in Java. I've found it thousands of time within the code but studying and playing with strings I've learnt that does not matter how many times you…
Carlo Bertuccini
  • 19,615
  • 3
  • 28
  • 39
2
votes
0 answers

Reuse Put in HBase client?

When put a new row to HBase, it is needed to create a new Put instance and call add(byte [] family, byte [] qualifier, long ts, byte [] value) to add data, which will create a KeyValue instance. If there are lots of put operations, lots of Put and…
DeepNightTwo
  • 4,809
  • 8
  • 46
  • 60
2
votes
0 answers

Object pool under memory constraints

We use a number of large objects. Ideally, we'd like to make all of them permanently available to client code, but they don't fit in physical memory all at once. So when we approach memory limits, we'll need to destroy some of the objects in pool…
max
  • 49,282
  • 56
  • 208
  • 355
1
vote
1 answer

Configuring Jetty to access a pool of shared objects

I have an object that processes text in a stateless way. It basically takes some input and returns the result. However, creating the object is expensive, as it needs to load a lot of data into memory. I would like to build a web service around it…
pako
  • 1,908
  • 4
  • 24
  • 40
1
vote
1 answer

Implementation of Object Pooling Concept in android

I am new to android, I need to use Object Pooling in my App, but I don't know enough about it. How might it be implemented?
Sanat Pandey
  • 4,081
  • 17
  • 75
  • 132
1
vote
1 answer

boost pool alternative to calloc

all, If you use boost pool library, how would you replace the following statement: MyStruct *someStruct = (MyStruct *) calloc(numOfElements, sizeof(MyStruct)); If it was for one element, I would do: boost::object_pool myPool; MyStruct…
pinpinokio
  • 505
  • 5
  • 19
1
vote
3 answers

How to use a List in a Function(Advanced)

I am using static lists of classes, and am trying to simplify or genericize the functions for ease of typing and copy/pasting. I'll try to explain the best I can: public static List allResources = new List(); public static…
WideEyeNow
  • 19
  • 3
1
vote
0 answers

How do I create a RecyclerView for Unity?

I'm trying to recreate android's RecyclerView on Unity using ScrollRect and Unity's object pooling system. I was able to make it work great when scrolling using the mouse, but when I drag up and down (for mobile) it just loads everything down very…
1
vote
1 answer

How to hide object pooling?

For context, I am creating a networking library and have internally implemented object pooling - instances of byte[] get reused in order to avoid creating constant garbage. For users of my library, I have exposed a public ref struct Packet which…
FICHEKK
  • 749
  • 1
  • 6
  • 24
1
vote
2 answers

Why does `x = 1234`, `y = 1234`, `x is y` return False in the REPL, but True in a stand-alone script?

I know there is something called interning in python, so basically x, y = 1, 1 print(x is y) # True x = 1234 y = 1234 print(x is y) # False However when I wrap it into a script and run with python command it prints True twice. My guess is there are…
kosciej16
  • 6,294
  • 1
  • 18
  • 29
1
vote
2 answers

In Unity, how do I dynamically modify a gameobjects tag based on a random selection made in another script?

Issue I'm trying to make a bubble/balloon popper style game and have a Spawner script (Spawner.cs) which holds a pool of objects (bubbles), this Spawner script then selects, at random, one of the objects that's in the pool. From here another script…
Twisted
  • 59
  • 7
1
vote
1 answer

Correct object pool implementation in C++?

I've been trying to find a way to implement an object pool in my project. I've found a few examples on the internet and most of them use std::lists and an example of it in a book; Game development patterns and best practices that also use…
AnotherBrian
  • 21
  • 1
  • 7
1
vote
0 answers

Object Pooling with Generics

I am trying to create a manager for object pools such that I can call a method from my manager in order to retrieve a reserved object in the pool or to create a new object when necessary. The objects to be pooled can vary greatly but must all…
Ryan T.
  • 197
  • 1
  • 15
1
vote
1 answer

How to write an generic object pool in c++

I want to write an generic object pool class and the object pool should be singleton, it is easy to access that object pool everywhere. template class Pool { T* _freeObjs; public: Pool& getInstance() { static…
constantJ
  • 13
  • 4
1
vote
1 answer

Pooled GameObject in Unity destroys itself after SetActive if Force is applied

When I retrieve an object from a list of created objects and reactivate it, it destroys itself, but only if I have force applied to start it moving. If I never apply force, everything works as intended and I can keep activating the object over and…
Freeman
  • 41
  • 6