Quick answer: Vulkan shader modules growing in memory across pipeline creation? VkShaderModule is only required during pipeline creation — destroy it right after to free memory.

A renderer creates 50 pipelines on startup. Each created a shader module and held onto it. Idle memory is 200MB higher than needed.

Module Lifetime

VkShaderModule is a handle to compiled SPIR-V. vkCreateGraphicsPipelines uses it during creation; once the pipeline is built, the module isn’t referenced again.

Destroy Immediately

vkCreateGraphicsPipelines(...);
vkDestroyShaderModule(device, vertModule, nullptr);
vkDestroyShaderModule(device, fragModule, nullptr);

Saves the module memory once the pipeline owns the compiled code.

Pipeline Cache for Cold Loads

Use VkPipelineCache serialized to disk. On second runs, pipeline creation skips the SPIR-V compile step — instant pipelines.

Hash for Validation

Pipeline cache files include a driver hash. After driver updates, the cache invalidates and you re-compile. Plan for occasional first-load hitches after driver bumps.

Verifying

Memory usage stable across pipeline creation. Subsequent runs after pipeline cache write are noticeably faster on startup.

“Destroy shader modules after pipeline creation. Cache compiled pipelines for fast cold loads.”

On every release, check the pipeline cache hit rate after first launch — sudden drops mean you broke binding compatibility somewhere.