Measure memory taken by requested view and response using pympler.muppy and/or psutil
Memory measurements can be:
- Displayed on Terminal, when running django development server
- Displayed on Loggin panel of django debug toolbar, if
SHOW_ON_DJANGO_DEBUG_TOOLBAR_LOGGIN_PANEL = True
- Sent to an email list, when the memory threshold is surpassed
Works with Debug = True or False
-
Run
pip install git+git://github.com/giussepi/django-memory-profiling
-
On settings.py
-
Add your preffered middleware(s) to MIDDLEWARE_CLASSES
'memory_profiling.psutil_middleware.MemoryUsageMiddleware',
'memory_profiling.pympler_middleware.MemoryMiddleware2',
'memory_profiling.pympler_middleware.MemoryMiddleware1',
- Add
memory_profiling
to INSTALLED_APPS - Configurate as desired. Example:
# MemoryMiddleware1 settings
SHOW_REQUEST_SUMMARY = True
SHOW_RESPONSE_SUMMARY = True
SHOW_COMPARED_REQUEST_RESPONSE_SUMMARIES = True
# MemoryMiddleware2 settings
SHOW_TOP_X_MEMORY_DELTAS = 15
# MemoryUsageMiddleware settings
MEMORY_VIEW_THRESHOLD = 10 # Mb
SHOW_MEMORY_USAGE_PER_REQUEST = True
MEMORY_WARNINGS_RECEIVERS = ['receiver@mail.com']
# General settings (applies to all memory_profiling middlewares)
IGNORE_URLS_CONTAINING = [
'site_media', 'static', '__debug__', 'undefined', 'pulse'
]
SHOW_ON_DJANGO_DEBUG_TOOLBAR_LOGGIN_PANEL = True