Code

Opened 7 years ago

Closed 6 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: UI/UX:

Description

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.

Attachments (0)

Change History (3)

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by ubernostrum

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 6 years ago by kcarnold

  • Resolution set to invalid
  • Status changed from new to closed

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

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.