Opened 13 years ago

Closed 12 years ago

#4111 closed (invalid)

Warning References stored in memory when DEBUG=True

Reported by: David Cramer <dcramer@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Django is storing references to the "Warning" exception (from the SQL engine) in memory when DEBUG mode is turned on. I believe this is not intended as it raises memory usage considerably and I can't see it's use anywhere.

Change History (3)

comment:1 Changed 13 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedAccepted

comment:2 Changed 13 years ago by James Bennett

Django stores a log of all the SQL in memory when DEBUG is True, and this is documented (along with a warning about memory use). Am I missing something obvious here that makes this a bug?

comment:3 Changed 12 years ago by Kenneth Arnold

Resolution: invalid
Status: newclosed

The only reference to Warning that I can find in django.db is in backends/mysql/

if settings.DEBUG:
    from warnings import filterwarnings
    filterwarnings("error", category=Database.Warning)

Since the Database module is loaded (in the django.db.backends.mysql.base module, plus the Python module cache), the Warning object, whether expensive or not, is getting stored anyway as one of its globals. Closing as invalid for now; feel free to reopen if I missed the point.

What you're probably seeing is the potentially huge memory use of django.db.connecction.queries when DEBUG is on, which is a separate issue.

Note: See TracTickets for help on using tickets.
Back to Top