#36137: Simple performance test using timeit and django.test.Client leads to
using
all available memory
-----------------------------------+--------------------------------------
Reporter: Vinay Sajip | Owner: (none)
Type: Bug | Status: closed
Component: Testing framework | Version: 5.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Simon Charette):
* resolution: => invalid
* status: new => closed
Comment:
Hello Vinay, there is unfortunately not much we can do from this report as
you've not provided details on how Django is at fault.
if you rewrite your test like the following
{{{#!python
def test_render_performance(self):
n = 2000000
for _ in range(n):
c = Client(headers={'user-agent': 'Mozilla/5.0 (X11; Linux
x86_64; rv:134.0) Gecko/20100101 Firefox/134.0'})
c.get('/admin/')
print(f'{int(t * 1000/n)} msecs')
}}}
you'll notice that the memory usage does not continue to increase in an
unbounded manner which likely means that the following statement
> the response returned from the `c.get('/admin/')` call isn't stored
anywhere and should be garbage collected, and it's not clear where the
memory leak is.
is likely a bad assumption and from looking at the output of `tracemalloc`
it appears that `timeit.timeit` keeps references to frames which prevents
`Client` instances assigned to `c` in them and their associated signal
receivers from being adequately garbage collected.
If you can reproduce without involving `timeit.timeit` or demonstrate how
Django is at fault please re-open.
--
Ticket URL: <https://code.djangoproject.com/ticket/36137#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/010701949f2a6602-f45768ea-4063-4191-8fb7-fa8df959a312-000000%40eu-central-1.amazonses.com.