r/ProgrammerHumor • • Oct 07 '26

Meme minecraftException

Post image
9.3k Upvotes

830 comments sorted by

View all comments

Show parent comment

3

u/TylerFL Oct 07 '26

If you're not using a reusable pool for something you're spawning en masse like that (or changing your data structure so it's in contiguous arrays instead of individual objects) you deserve the GC hit

My favorite thing about bullet hell games is pointing out that the bullets get reused if they optimized the code! If you have at most 1000 bullets on the screen, you just keep them in memory and use the same ones over and over.

3

u/Ok-Scheme-913 Oct 09 '26

To be honest, reusable pools are not the panacea. They can actually make certain workloads SLOWER. Like, in java ultra-short lived objects are basically free, storing them may not be worth it in all cases.

The one true thing: always measure