Technologies/Django/process.runtime.cpython.memory
DjangoDjangoMetric

process.runtime.cpython.memory

Python process memory usage
Dimensions:None
Available on:OpenTelemetryOpenTelemetry (1)
Interface Metrics (1)
OpenTelemetryOpenTelemetry
Memory usage of the Django Python process
Dimensions:None

Technical Annotations (41)

Configuration Parameters (7)
iterator.chunk_sizerecommended: 1000
number of records to process per batch, prevents loading entire queryset into memory
chunk_sizerecommended: 2000 (default), tune down for wide rows, up for narrow ones
Controls how many rows .iterator() fetches at once from database cursor
memory_limit_mbrecommended: 500
memory threshold for monitoring and alerting
page_sizerecommended: 50
Default pagination size for list endpoints when client doesn't specify
statement_timeoutrecommended: 10000
PostgreSQL query timeout in milliseconds to kill runaway queries
CACHES.BACKENDrecommended: django.core.cache.backends.locmem.LocMemCache
local-memory backend unsuitable for production multi-process setups
CACHES.default.BACKENDrecommended: django.core.cache.backends.redis.RedisCache or django.core.cache.backends.memcached.MemcachedCache
Use shared backend instead of locmem for production
Error Signatures (3)
timeout errorslog pattern
Connection pool exhaustedlog pattern
OOM-killedlog pattern
CLI Commands (6)
dmesg | grep -i "killed process"diagnostic
htopmonitoring
for txn in Transaction.objects.filter(status='pending').iterator(chunk_size=2000):diagnostic
import gc del qs gc.collect()remediation
os.kill(pid, 0)diagnostic
EXPLAIN ANALYZE SELECT * FROM orders ORDER BY created_at DESC LIMIT 50 OFFSET 0;diagnostic
Technical References (25)
OOMKilledconceptsystemdcomponentQuerySet.iterator()componentORMconceptprefetch_relatedcomponentPrefetchcomponenttracemalloccomponentpsutilcomponentMIDDLEWAREcomponentannotate()componentCountcomponentSumcomponent_result_cachecomponent.iterator()component.values()componentgc.collect()componentOOM killerconceptPIDconceptchild_pidcomponentOrder.objects.all()componentiterator()componentQuerySetcomponentmanagement commandcomponentLocMemCachecomponentdjango.core.cache.backends.locmem.LocMemCachecomponent
Related Insights (14)
Gunicorn workers killed by OOM causing Bad Gateway errorscritical
Memory leak from loading entire queryset into RAMcritical
Prefetch loads millions of related objects causing memory explosionwarning
Memory monitoring middleware detects per-request memory leaks over 100MBinfo
Annotated querysets with aggregates load massive result sets into memorywarning
Queryset result cache causes unbounded memory growth on large datasetscritical
Python garbage collector cannot free queryset memory while references remainwarning
Child processes killed by OOM or crashes leave orphaned taskscritical
High memory consumption in task workers requires process isolationwarning
Unpaginated list endpoints cause outage at scalecritical
Synchronous bulk exports cause memory exhaustion and timeoutcritical
Django QuerySet full result caching causes OOM in batch processingcritical
Local-memory cache inefficient in multi-process deploymentswarning
LocMemCache creates isolated per-process cache instanceswarning