Jenkins

Memory Exhaustion from Build Artifact Accumulation

critical
Resource ContentionUpdated Nov 5, 2024

Jenkins heap memory fills up due to insufficient build discard policies and accumulation of old artifacts, leading to OutOfMemoryError crashes and service unavailability.

How to detect:

Monitor heap memory usage ratio (vm.memory.heap.usage). Alert when heap usage exceeds 85% for 3+ minutes. Check disk space on /var/lib/jenkins for artifact storage exhaustion. Look for correlation with build count and artifact retention.

Recommended action:

Increase JVM heap space with -Xmx flags (minimum 2GB for production). Implement buildDiscarder with logRotator to retain only recent builds. Enable cleanWs() in pipeline post-actions. Archive critical artifacts to external storage (S3, Artifactory).