micdoodle8 / Galacticraft

An advanced Space Dimension Mod for Minecraft
Other
617 stars 332 forks source link

Only initialize render lists in SkyProviderOrbit once (fix client memory leak, greatly improve space station FPS) #4048

Closed Combustible closed 3 years ago

Combustible commented 4 years ago

After much debugging, figured out that SkyProviderOrbit is being instantiated many times. It seems like it was originally designed to be instantiated once/a small number of times, then render() called on it many times.

Instantiating this class many, many times was leading to a memory leak where many copies of the openGL display lists were instantiated but never free'd.

This patch changes those display lists to only instantiate once and be re-used by any subsequent instance of SkyProviderOrbit. This should fix the memory leak and improve overall rendering performance.

Somewhat anecdotal, but this brings my FPS from ~20 to my monitor's 120 vsync. The sky still animates on my space station... seems to work well but not sure how else to test this.

micdoodle8 commented 3 years ago

Well that's gone unnoticed for quite a long time. Thanks for the fix!

Combustible commented 3 years ago

Welcome! Thanks for merging. Galacticraft really inspires me, it's just fun to imagine building something in space.