with one click
with one click
Guide for investigating slow PostgreSQL queries
AWS Lambda High Latency Troubleshooting
Troubleshooting Application Gateway Problems
Database Connection Troubleshooting
Service Connectivity Issues
Use this skill when the user asks to "patch a CVE", "fix a CVE", "handle a CVE", "check a CVE", or discusses Docker image vulnerabilities, docker scout findings, or Go/dependency CVE remediation in the Dockerfile.
| name | python-memory-troubleshooting |
| description | Python Application Memory Troubleshooting |
This runbook helps diagnose memory issues in Python applications running in Kubernetes.
Check if the application pods are running and review recent events:
kubectl get pods -n {namespace} -l app={app_name}
kubectl describe pod -n {namespace} -l app={app_name}
kubectl top pod -n {namespace} -l app={app_name}
Look for memory errors, GC warnings, or memory-related messages:
kubectl logs -n {namespace} -l app={app_name} --tail=100 | grep -E "(memory|Memory|ERROR|WARNING|GC|Cache|processed)"
Pay attention to:
Look for common memory leak patterns in logs:
# Check for growing collections or caches
kubectl logs -n {namespace} -l app={app_name} | grep -E "size:|count:|total:|cache"
# Look for processing patterns
kubectl logs -n {namespace} -l app={app_name} | grep -E "Processing|processed|Batch"
Common memory leak indicators:
Analyze how memory usage correlates with application activity:
# Monitor memory growth over time
kubectl top pod -n {namespace} -l app={app_name} --use-protocol-buffers
# Correlate with processing activity
kubectl logs -n {namespace} -l app={app_name} --tail=50
Check memory usage patterns over time:
# Get current memory usage
kubectl top pod -n {namespace} -l app={app_name}
# Review resource limits
kubectl describe pod -n {namespace} -l app={app_name} | grep -A3 "Limits:"
If the application has profiling endpoints or debug mode:
# Check if app exposes memory profiling endpoints
kubectl exec -n {namespace} {pod_name} -- curl localhost:8000/debug/memory 2>/dev/null || echo "No debug endpoint"
# If the app uses Flask/Django debug toolbar
kubectl port-forward -n {namespace} {pod_name} 8000:8000
# Then visit http://localhost:8000/debug
# Check if py-spy is installed
kubectl exec -n {namespace} {pod_name} -- which py-spy
# If available, profile the running process
kubectl exec -n {namespace} {pod_name} -- py-spy dump --pid 1
Look for tracemalloc output in logs:
kubectl logs -n {namespace} -l app={app_name} | grep -E "tracemalloc|Top.*memory blocks"
Check for memory allocation patterns in logs:
# Look for object creation patterns
kubectl logs -n {namespace} -l app={app_name} | grep -E "Created|Allocated|New.*object"
# Check garbage collection activity
kubectl logs -n {namespace} -l app={app_name} | grep -E "gc\.|GC|garbage"
Unbounded Collections: Lists/dicts that grow without limits
Cache Without Eviction: Caching data without removing old entries
Keeping References to Large Objects: Storing processed data unnecessarily
Global State Accumulation: Module-level variables that accumulate data
Circular References: Objects referencing each other preventing GC
Large Object Allocation: Creating unnecessarily large objects