Opened 8 years ago
Closed 8 years ago
#27066 closed Uncategorized (needsinfo)
Possible Memory leak while evaluating a QuerySet
Reported by: | Ramez Issac | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Normal | Keywords: | queryset evaluation memory leak |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I discovered this as i have a 150K rows QuerySet,
I checked its existence by the not efficient
if queryset: pass
However, as soon as execution hits this line, memory consumption jumps big time and it never goes back to normal unless uwsgi process gets restarted.
This information has been noticed using htop showing the relevant uwsgi process.
Using query.exists() is working perfectly good.
Change History (6)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Thank you dear time for your quick reply,
What i'm referring to here is when i made the mistake of using bool(queryset)
, the server memory jumped and never returned back to normal even after the function exit.
Something is not right here.
The only way to bring the memory back to normal was by restarting the uwsgi process running the django instance.
It's not about that the line bool(queryset)
takes longer time to execute, or is heavy on memory;
But this line have a long lasting side effect on server memory consumption.
comment:3 by , 8 years ago
I'm not intimately familiar with memory management in Python but unless you can provide details as to why, I'm doubtful that Django is at fault for this behavior. Maybe this post about Diagnosing Memory "Leaks" in Python helps.
comment:5 by , 8 years ago
@claudep Lol Nope ! :D
@Tim I'll review the document you attached and get back to you with more detailed/insightful information.
comment:6 by , 8 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
As the documentation says:
Can you provide more details if that doesn't address your concerns?