# Text Pooling Optimizations

In my game I have created popup text for gained points when enemies are killed. it pops up wherever the enemy was and will say something like "+32" float up a bit and fade away at the same time. This transition lasts for a few seconds if that. and hundreds could appear at a time when AoE attacks destroy a lot of enemies.

That's all well and good. and it works! but I fear that this could become quite slow on mobile devices. So I did what any good game dev does. I pooled it!

Then it occurred to me. I'll still be changing the display value of the text elements dynamically and libraries like TextMeshPro already, in surely an optimized way, instantiate actual meshes to render text. So is pooling these text elements really a big optimization?

so here goes my question for experienced and knowledgeable devs. Is it more efficient to pool each character I need and assemble my short strings dynamically as sets of pooled gameobjects for these popups of just a few characters or should I simply pool text elements that will change their text just before appearing? Assume the memory usage difference is minimal. only worried about speed.

This is on top of the game having possibly thousands of projectiles moving at any given time, so I believe it is a valid optimization question, but I ask this more for curiosity than practicality. For now, I already have a working solution. but I believe such an issue could arise in the future. and want to satisfy my curiosity now.

• Have you tried profiling these options on your target hardware to find out how they perform? This will give you information that's much more trustworthy than "some rando on the Internet said this way was better" – DMGregory Aug 8 '19 at 3:43
• DMGregory is right, you need to profile your game to know where is the real bottleneck. Yes, the Instantiate method is known to be slow, so pooling gameobjects is the right thing. Pooling characters is not worth it, but if you really want, you can treat them the same as bullets (I don't know how you handle them but from my experience a particle system will do). But please use the profiler first, there's a high probability that you don't have to optimize damage labels. – trollingchar Aug 8 '19 at 6:16
• Just treat your numbers/text as sprites - far simpler than managing text, meshes, etc. Sprite libraries are designed to handle huge numbers of particles, and can deal with fade, scale, etc. – Tim Holt Aug 8 '19 at 6:39
• The goal of asking this question is to ascertain knowledge about how to optimize usage of something as uniquely implemented as text rendering. And while my phone will handle these issues well, lower end devices may not, I'd like to hear experienced knowledge to help me learn more about the subject as i find the thought more interesting than practical. Like i said. Its about my curiosity – Jody Sowald Aug 9 '19 at 4:20