Opened 10 years ago
Closed 9 years ago
#24745 closed Cleanup/optimization (fixed)
Django 1.8+ Migrations Hold Onto Way More Memory
Reported by: | James Pulec | Owned by: | Markus Holtermann |
---|---|---|---|
Component: | Migrations | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After bumping to 1.8, rendering model states when running migrate seems to consume a lot more memory. Somewhere on the order of 4x-6x more. It doesn't look like this memory is properly released back to the OS after running migrate, and just hangs around.
I discovered this calling manage.py test when using a custom test runner that makes a subprocess call, and was unable to do so, because the python process was already consuming so much memory that os.fork() couldn't create a new process.
Change History (8)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Testing with 1.8.1 seems to yield the same results. Somewhere around 1GB of virtual memory is being held after rendering the model migrations, and then my test runner fails to fork. However, running with the flag --keepdb
runs smoothly as I would expect.
I'm working on trying to run against master, but I have so many dependencies that break against master that it might take some time.
comment:3 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Bug → Cleanup/optimization |
follow-up: 5 comment:4 by , 10 years ago
For reference, I finally managed to run my tests against master. They pass, but I think the margin is pretty slim. The VM I do all my testing in has 2GB of RAM. On 1.8 and 1.8.1 my running test holds onto ~47% of my ram according to top. On master that number comes down closer to 37% so it runs for my use case.
However, it still shows that running all those migrations on creation of a test database gobbles up all that ram and doesn't seem to release it right away.
comment:5 by , 9 years ago
I've encountered the exact same problem. Our virtual machines used for development would require 2GB of memory just to run migrations (as opposed to the 512 they use now). We cannot upgrade until this is resolved.
comment:6 by , 9 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Could you give the pull request https://github.com/django/django/pull/5178 a try.
comment:7 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Did you test with 1.8.1 after #24591? The solution for that ticket is a bit different on master, so testing there for comparison would also be useful.