File: django.rst

package info (click to toggle)
pympler 1.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,196 kB
  • sloc: python: 9,816; javascript: 2,775; makefile: 17
file content (39 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.. _django:

=========================
Tracking memory in Django
=========================

Introduction
------------

Pympler includes a memory profile panel for Django that integrates with the
`Django Debug Toolbar <https://github.com/jazzband/django-debug-toolbar>`_. It
shows process memory information and model instances for the current request.

Usage
-----

Pympler adds a memory panel as a third party addon -- it's not included in the
Django Debug Toolbar. It can be added by overriding the `DEBUG_TOOLBAR_PANELS`
setting in the Django project settings::

    DEBUG_TOOLBAR_PANELS = (
        'debug_toolbar.panels.timer.TimerDebugPanel',
        'pympler.panels.MemoryPanel',
        )

Pympler also needs to be added to the `INSTALLED_APPS` in the Django settings::

    INSTALLED_APPS = INSTALLED_APPS + ('debug_toolbar', 'pympler')

Known issues
------------

Pympler doesn't correctly handle tracking calls from concurrent threads. In
order to get accurate instance counts and sizes, it's recommended to only use
single-threaded web servers for memory profiling, e.g.::

    django-admin runserver --nothreading

.. automodule:: pympler.panels