+3 votes

Object pool is very commonly used in game development. But there is no build-in object pool in Godot. What's the best way to make it?

Maybe need to create a module in C++? Any suggestion?

in Engine by (24 points)
edited by

In a Reddit post, I read reduz's post that Godot doesn't need object pooling. I also like to know more about this. May be object pooling is not needed but in the case of instantiation we may need to create all instances at first and keep it in an array.
Someone from the dev team can explain.

Can't find the post on reddit. Why Godot doesn't need object pooling? Are the objects instanced in GDScript pooled by C++ code?

Checked the links. It solved the segmentation problem with the memory model. But not the time consume if a lot of instances need to be create frequently like bullets or small visual effects.

Maybe the time consume is very small so we can just ignore it?

There is no GC in gdscript so your game wont pause in random moments of time to free the memory, this is why there is no need for object pooling in gdscipt.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.