Object pooling - Object caching. Currently trying to learn Blueprints.

Hey all, I am fairly new to UE4. I come from a Unity background and I would like to know a few things about performance around creating objects at run time and object pooling.

First, I realise that object pooling will always be more efficient but how important is it in UE4, how much memory management does it do for you etc.
In Unity I would approach a project with pooling in mind as it is almost always necessary for any good level of performance, in this tutorial series https://www.youtube.com/watch?v=qzFd-PfM5kc&index=3&list=PLZlv_N0_O1gbY4FN8pZuEPVC9PzQThNn1 for instance I figure the floors and the objects would be better set from a pool and moved around the scene opposed to destroying and then creating a brand new object constantly.

Finally, with the above in mind, coding an object pool makes perfect sense to me, however I cannot get my mind around how to do that with Blueprints can anyone provide or point me to an example of how this might be implemented???

Thanks in advance for any insight into this.

Instanced Static Meshes are awesome for increasing performance. Check out Rama’s Work. I still believe Object Caching is relevant. Drummed up this Object Pool Actor to help you get you going. Its divided into 3 Functions: CreateObjectPool, GetFromObjectPool, & ReturnToObjectPool. There is a Test BP in the main event graph to step through and see it at work:

https://arcadekomodo.com/home/wp-content/uploads/2015/03/Screenshot-2015-03-13-06.42.33-150x150.png

Good Luck.

As the above shows, object pooling in Blueprint would be the same as how you would do it in code.

Spawn your actors and add them to an array of that object type, then just call them off as required. As far as whether you need to do it in UE4, I would say yes as the GC still exists, just UE4’s version of it (as native C++ doesn’t do any).

Object pooling is a pain as opposed to create/destroy, but it does save you the headache of the GC kicking in when you dont want it to. That goes for any engine regardless of the language.

Perhaps to make as painless as possible , one could probably make the Class handle any type of object, add in overflow, and rename the functions to something more familiar InitPoolObjects, CreatePoolObject, & DestroyPoolObject. This what I’m doing for custom mesh occlusion in certain areas of the level map.

I was given the task to make playable a game level with 1.000+ projectiles flying around.
The funny thing was that after spawning/destroying just 200 of them, my fps dropped to near 20fps.

I tried making a blueprint for it, but was slow too then I’ve switched to code and finally implemented a feature complete plugin which generates and manages object pools for me.
My fps went from 24ms to just 4ms; from 27fps to (a max of) 86fps on 4K resolution with 1.000 bullets flying on screen.
This is awesome, I think I’m gonna share this plugin once create a video and some tutorial for it.

1 Like

[MENTION=434]BrUnO XaVIeR[/MENTION] are you using instanced static meshes or something? Where are created objects stored, randomly in the game world simply hidden and with disabled collision?

I didn’t use instanced meshes because the game bullets needs to be real actors with physics simulation and collision detection, and also be able to have different materials applied;
In this thread I’ve created for it there some more details about it: