The developers identified a memory consumption issue in a speech recognition service running on PyTorch 2.9.1, GigaAM-v3, and silero-VAD. The service, running in a Docker container with an 8 GB memory limit, was consistently hitting its threshold due to excessive anonymous memory usage.

Initial investigation revealed that the glibc memory allocator was fragmenting memory across multiple threads. Setting the MALLOC_ARENA_MAX environment variable to 2 reduced memory growth but did not solve the issue entirely, as the service continued to consume up to 6.6 GB of RAM.

The root cause was identified as the cuDNN cache, which stores execution plans for convolutional layers. Because the VAD component segments audio into fragments of varying lengths, the system generated a unique plan for each shape, quickly filling the cache. Each plan occupied approximately 1.9 MB, significantly larger than the 200 KB estimated by PyTorch documentation.

To stabilize memory usage, the team set the TORCH_CUDNN_V8_API_LRU_CACHE_LIMIT to 1024. This configuration successfully capped memory consumption at approximately 4.5 GB, preventing OOM events while maintaining acceptable performance levels for the application.