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
1 answer

Unity Object Pool Objects Invisible

The following code below shows what I made. (Pooled square is a game object I set up in another c# file) [SerializeField] private Camera mainCamera; private List PooledSquares = new List(); private Camera cam; // Update is…
Athsmooth
  • 45
  • 6
0
votes
2 answers

Need help with pooling in Memcached

I have a web application running on multiple servers. And I am planning to implement Memcached into this app with spymemcached as the client. I have created a pool of memcached clients. But I am not sure if the client being borrowed from the pool…
0
votes
0 answers

Is this a more optimized alternative to instantiate?

I'm trying to make a custom object pooling class (this is my first time trying to avoid using Instantiate(). I know object pooling is objectively better than instantiating but I'm worried that the way I set it up might actually be worse than…
John
  • 197
  • 1
  • 17
0
votes
1 answer

Pooling regular (non-GameObject) C# reference types in Unity games?

Most Unity developers are aware that instantiating and destroying GameObjects repeatedly is something to avoid because it generates some garbage. But a discussion came up about whether it's more efficient to pool regular C# classes (non-GameObject…
0
votes
0 answers

What is the best way to fully clear a DOM element for use in a pool?

I am considering using object pooling of DOM nodes. When a DOM node is done being used, it would be put into a pool. I have something like this currently. function removeNativeElement(virtualElement, store) { let stack = [virtualElement] let els…
Lance
  • 75,200
  • 93
  • 289
  • 503
0
votes
1 answer

Whats the best practice for object pool pattern in flutter/dart?

Imagine a very simple application with two pages, PostList and PostDetail. On the former page, we show a list of posts, and on the latter, the details of a single post. Now consider the following scenario. Our user clicks on the first PostItem and…
0
votes
1 answer

Unity3D: How to do object pooling without a spawner singleton

Usually, if you use object pooling, you make a singleton like in this video. After seeing this video, I discovered how messy singleton can be. Is there any other way to do object pooling without using singletons? I wanna instead use Events.
SushiWaUmai
  • 348
  • 6
  • 20
0
votes
2 answers

Errors at ObjectPooling

im working at a infinit runner game and i want to add objectpooling to the platforms, but i got 2 errors: Assets\PlatformGenerator.cs(37,26): error CS1501: No overload for method 'SpawnObject' takes 1 arguments Assets\ObjectPool.cs(36,16): error…
0
votes
3 answers

Does object pool pattern requires creation of objects before they even needed

If I use object pool design pattern, do I have to create the objects before that anyone needs them, or that I can create every object only when someone needs it, and then (after he used it), put it in the pool? Thus, to start with an empty pool, and…
Dani
  • 719
  • 1
  • 7
  • 14
0
votes
0 answers

Object dynamic constness

I am right now facing issue with my design. I am handling situation of master-server and semi-slave-client. I have server which practically speaking – can do whatever it desires. (Lets don't deconstruct network layer, as it is already working…
Black
  • 312
  • 2
  • 15
0
votes
1 answer

"Cannot reuse the bullets in obectpool."

When bulletpool is being instantiated, I can shoot bullets. But when all the bullets are done instantiated, I can't shoot the bullet. IDK where is the porblem.. BulletPoolScript: public class scriptBulletPool : MonoBehaviour { private static…
0
votes
1 answer

For some reason when I reactivate objects in my object pool they are static?

I'm currently working on a game and I ran into a small issue. I'm currently trying to create an object pool for objects that will reappear constantly in my game in order to improve the framerate of my game. However when creating this object pool…
0
votes
0 answers

Can I reuse Java Kafka Consumer?

I want to have consumer pool and reuse each consumer. Is it correct? KafkaConsumer consumer = createConsumer(); TopicPartition topicPartition = new TopicPartition("topic", 2); consumer.assign(List.of(topicPartition)); consumer.seek(topicPartition,…
Max
  • 1,803
  • 3
  • 25
  • 39
0
votes
1 answer

Object Pool notify not working

I am trying to make an Object Pool, program and output is given below. The issue I am facing here is that after leaving the object and calling notify or notifyAll (line 1 highlighted in program), the waiting threads does not get started. Can anyone…
0
votes
1 answer

Single reference into multiple objects

I am a bit lot about what to do in an OO/DB relation... Here is the DB model : CREATE TABLE User Id CREATE TABLE Location userId // EDIT oups, wrong ! // placeId // Should be : seatId CREATE TABLE Game locationId Now…
Antoine
  • 480
  • 1
  • 4
  • 15